Skip to content

Retire legacy flat error-body fallback + adopt decodeApiError once API is fully nested #342

Description

@zachdunn

The CLI's apiErrorMessage() (src/lib/errors.ts) carries two backward-compat seams from the standardized-errors migration (buildinternet/releases#1830) that can be retired once the API is fully on the nested envelope:

  1. Legacy flat { message } fallback (errors.ts:82-83) — reads a top-level message when the body isn't the nested { error: { message } } shape.
  2. Inline stand-in for decodeApiError — the whole function is a hand-rolled reader; the comment already says "Swap for decodeApiError().message once [api-types] exports the errors module."

Why not yet

The legacy flat fallback is still load-bearing: the API's auth middleware/guards have not been migrated and still emit the flat shape { error: "unauthorized", message: "Sign in required" } (tracked in buildinternet/releases#1839). For those responses body.error is a string, so apiErrorMessage skips the nested branch and relies on the flat body.message fallback. Dropping it today would regress 401/403/429 auth-failure messages to bare res.statusText ("Unauthorized").

Adopting the published decodeApiError is separately blocked on an api-types release carrying the errors module + a subpath export (buildinternet/releases#1840).

Retire when

Low priority; purely dead-code cleanup once both upstreams land. No user-facing behavior change (the CLI is a pure pass-through of error.message).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions