fix: show real error text in Account Hub instead of "[object Object]"#52
Merged
Merged
Conversation
Flash GraphQL mutations return validation failures as an array of
{ message } objects, but every Account Hub action handler rendered them
with `result.errors.join(", ")`, which String()-coerces each object to
"[object Object]". This masked the actual reason on Change Level, Lock/
Activate, Update Phone, Validate Merchant, and Delete Merchant.
Add a formatApiErrors() helper that extracts .message from each error
object and route all five handlers through it. Plain strings and string
arrays are unchanged; unexpected object shapes fall back to JSON rather
than "[object Object]".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The Account Hub error dialog shows
[object Object]instead of the real reason a mutation failed:Root cause
Every Flash GraphQL mutation the page calls returns validation failures as an array of
{ message }objects — e.g.accountUpdateLevelreturnserrors { message }. All five Account Hub action handlers rendered them with:Array.joincallsString()on each element, so[{message: "..."}]becomes"[object Object]". The screenshot is the Change Level action — the mutation returned a real business-logic reason and the UI threw the text away.The same latent bug was present in all five handlers: Change Level, Lock/Activate, Update Phone, Validate Merchant, Delete Merchant.
The fix
Add a single
formatApiErrors()helper that extracts.messagefrom each error object and route all five handlers through it.[{message}](the bug) → renders the actual message[object Object]Verification
node --checkpasses on the file."Account is already at MERCHANT level"instead of"[object Object]", with no regression on string/array inputs.Manual test plan (TEST → PROD)
[object Object].Out of scope (noted, not changed)
The
error:callbacks on these samefrappe.calls readerr?.responseJSON?.exception || err?.message, which doesn't surface the server message when an endpoint returns via the@handle_api_errorsdecorator (that lands aterr.responseJSON.message.error). Genuine 500s currently show the generic "Failed to …" fallback. Happy to follow up separately if wanted.🤖 Generated with Claude Code