fix(app): read the message from structured server error payloads - #39180
Open
IbrahimKhan12 wants to merge 1 commit into
Open
fix(app): read the message from structured server error payloads#39180IbrahimKhan12 wants to merge 1 commit into
IbrahimKhan12 wants to merge 1 commit into
Conversation
For declared error statuses the promise client throws the raw parsed JSON body rather than an Error, so every server NamedError without a dedicated branch in formatServerError rendered as "Unknown error" even though its payload carried data.message. Extract data.message, then a top-level message, after the existing Error and string branches so those keep their exact behavior, and before the caller's fallback so a real message wins over a generic one. The error name is deliberately not used as a fallback, so payloads carrying no message at all still reach the existing unknown-error text. Fixes anomalyco#31643
IbrahimKhan12
force-pushed
the
structured-error-message
branch
from
July 27, 2026 20:19
70d9800 to
de9c86d
Compare
IbrahimKhan12
marked this pull request as ready for review
July 27, 2026 20:19
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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.
Issue for this PR
Fixes #31643
Type of change
What does this PR do?
Structured API failures often arrive as plain objects instead of
Errorinstances.formatServerErrorhandled typed config/model errors,Errorobjects, and strings, but otherwise discarded usefuldata.message, top-levelmessage, andnamefields and showedUnknown errorin app and desktop error toasts.This change reads non-empty nested and top-level messages from unrecognized structured payloads, then uses a meaningful structured error name before the generic fallback. Existing typed-error precedence is unchanged, and blank messages or the generic
UnknownErrorname still use the translated fallback.How did you verify your code works?
bun test src/utils/server-errors.test.tsfrompackages/app: 16 tests pass, including nested messages, top-level messages, blank values, named fallback, and existing typed errors.bun typecheckfrompackages/app: existing workspace dependency-resolution errors remain; no errors are reported in the changed files.Screenshots / recordings
N/A, this changes error formatting only.
Checklist