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:
- Legacy flat
{ message } fallback (errors.ts:82-83) — reads a top-level message when the body isn't the nested { error: { message } } shape.
- 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).
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:{ message }fallback (errors.ts:82-83) — reads a top-levelmessagewhen the body isn't the nested{ error: { message } }shape.decodeApiError— the whole function is a hand-rolled reader; the comment already says "Swap fordecodeApiError().messageonce [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 responsesbody.erroris a string, soapiErrorMessageskips the nested branch and relies on the flatbody.messagefallback. Dropping it today would regress 401/403/429 auth-failure messages to bareres.statusText("Unauthorized").Adopting the published
decodeApiErroris separately blocked on an api-types release carrying the errors module + a subpath export (buildinternet/releases#1840).Retire when
{ message }fallback is dead and can be removed.decodeApiError+ importable subpath) — then replace the inlineapiErrorMessagebody withdecodeApiError().message.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).