Skip to content

fix: catch array errors from API and display error message more detailed#789

Merged
smarcet merged 2 commits intomasterfrom
fix/snackbar-error-array
Feb 11, 2026
Merged

fix: catch array errors from API and display error message more detailed#789
smarcet merged 2 commits intomasterfrom
fix/snackbar-error-array

Conversation

@tomrndom
Copy link

@tomrndom tomrndom commented Feb 11, 2026

ref: https://app.clickup.com/t/86b8eh2xm

image

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • Style

    • Minor syntax cleanup with no functional changes.
  • Chores

    • Updated an internal dependency to a patch release.
  • Other

    • No user-facing behavior or API changes.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Two small edits: a syntactic change adding a semicolon to the end of snackbarErrorHandler in src/actions/base-actions.js, and a dependency version bump for openstack-uicore-foundation from 4.2.22 to 4.2.23 in package.json.

Changes

Cohort / File(s) Summary
Actions file (minor syntax)
src/actions/base-actions.js
Added a trailing semicolon to the snackbarErrorHandler function closing; no behavioral changes.
Dependency bump
package.json
Updated openstack-uicore-foundation dependency from 4.2.22 to 4.2.23.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • smarcet

Poem

🐰 I hopped in to tweak a line,
A semicolon, tidy and fine.
A version nudged, then off I go,
Quiet changes — soft and slow. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to catch array errors and display detailed messages, but the actual changes only include a minor semicolon fix and a dependency version bump with no error handling logic added. Update the title to accurately reflect the changes: e.g., 'chore: add semicolon to snackbarErrorHandler and bump openstack-uicore-foundation version' or align implementation with the stated objective.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/snackbar-error-array

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/actions/base-actions.js`:
- Around line 52-56: The code is rendering API error strings into HTML unsafely;
update the call to setSnackbarMessage in the error path to avoid XSS by either
escaping/sanitizing the entries in the errors array before joining or by sending
them as plain text instead of HTML. Specifically, change the payload for
setSnackbarMessage (the call inside this function) to not use the html property
with errors.join("<br>") — either escape each item in errors then join and keep
a sanitizedHtml property, or replace html with a text/message property like
errors.join("\n") (and ensure consuming code uses text rendering), preserving
the type and code (err.status || 0) and keeping setSnackbarMessage(dispatch,
state) usage.
🧹 Nitpick comments (1)
src/actions/base-actions.js (1)

47-56: Handle non-string elements in the errors array.

If the API returns error objects instead of strings (e.g., [{ message: "..." }]), errors.join("<br>") will produce "[object Object]<br>..." which is not user-friendly. Consider validating element types or extracting message properties.

♻️ Proposed defensive handling
   const errors = err.response?.body?.errors;
 
-  if (Array.isArray(errors) && errors.length > 0) {
+  if (Array.isArray(errors) && errors.length > 0) {
+    const errorMessages = errors.map((e) =>
+      typeof e === "string" ? e : e?.message || JSON.stringify(e)
+    );
     dispatch(stopLoading());
 
     return setSnackbarMessage({
       type: "warning",
-      html: errors.join("<br>"),
+      html: errorMessages.join("<br>"),
       code: err.status || 0
     })(dispatch, state);
   }

Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom please review comments

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@smarcet smarcet merged commit b7e82b1 into master Feb 11, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants