Skip to content

fix(app): read the message from structured server error payloads - #39180

Open
IbrahimKhan12 wants to merge 1 commit into
anomalyco:devfrom
IbrahimKhan12:structured-error-message
Open

fix(app): read the message from structured server error payloads#39180
IbrahimKhan12 wants to merge 1 commit into
anomalyco:devfrom
IbrahimKhan12:structured-error-message

Conversation

@IbrahimKhan12

@IbrahimKhan12 IbrahimKhan12 commented Jul 27, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #31643

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Structured API failures often arrive as plain objects instead of Error instances. formatServerError handled typed config/model errors, Error objects, and strings, but otherwise discarded useful data.message, top-level message, and name fields and showed Unknown error in 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 UnknownError name still use the translated fallback.

How did you verify your code works?

  • bun test src/utils/server-errors.test.ts from packages/app: 16 tests pass, including nested messages, top-level messages, blank values, named fallback, and existing typed errors.
  • bun typecheck from packages/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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
IbrahimKhan12 force-pushed the structured-error-message branch from 70d9800 to de9c86d Compare July 27, 2026 20:19
@IbrahimKhan12
IbrahimKhan12 marked this pull request as ready for review July 27, 2026 20:19
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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.

formatServerError shows Unknown error for structured API payloads

1 participant