mirror of
https://github.com/Comfy-Org/comfy-typescript-sdk.git
synced 2026-11-04 23:47:27 +00:00
[PR #205] fix(errors): keep the message of a bare {message} error body #204
Labels
No labels
audit:ai-readiness
audit:community
audit:github
audit:health-scoring
audit:policy
audit:release
audit:supply-chain
bug
cursor-review-pin
effort:medium
effort:small
effort:trivial
priority:nice-to-have
priority:recommended
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-typescript-sdk#204
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/205
Author: @mattmillerai
Created: 10/9/2026
Status: 🔄 Open
Base:
main← Head:be-19945-bare-message-fallback📝 Commits (3)
afbcbb2fix(errors): keep the message of a bare {message} error bodyc0af5f4fix(errors): guard the BY_CODE lookup and treat a non-string envelope message as absent4d2c7b7fix(errors): leave the BY_CODE own-property guard to #196📊 Changes
5 files changed (+82 additions, -1 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
src/low/errors.test.ts(+48 -0)📝
src/low/errors.ts(+12 -1)📝
src/sdk/client.test.ts(+12 -0)📝
test/support/stub-server.ts(+9 -0)📄 Description
ELI-5
When the server rejects a job before it reaches the API's own error handling (for example, a body that isn't valid JSON, a
workflowthat isn't an object, or a workflow over the size limit), the web framework answers with a plain{"message": "..."}body instead of the usual{"error": {...}}envelope. The SDK only looked insideerror, so the useful explanation was thrown away and you just sawHTTP 400. Now the SDK keeps that message.Summary
src/low/errors.ts:ErrorEnvelopeBodygains an optional top-levelmessage(documented as echo'sHTTPErrorshape, not part of the ErrorEnvelope contract). InerrorFromEnvelope, an empty or non-string envelope message is treated as absent, and then a non-empty stringbody.messageis used. The code stays status-derived (CODE_BY_STATUS[status] ?? "error"),detailsstaysnull, and a non-empty envelope message still wins when a body carries both. With no usable message on either side, the result isHTTP <status>(a non-string envelope message used to be stringified, e.g.[object Object]).test/support/stub-server.ts: a newjobBareError: { status, message } | nullscenario makesPOST /jobsanswer with a bare{message}body.src/low/errors.test.tsfor the decoder 400, the 413, envelope-wins-over-top-level, ignoring a non-string or emptymessageat either level (42,"",{x:1}), and an empty envelope message falling back to the top-level one. There's also an end-to-endsubmit()case insrc/sdk/client.test.tsagainst the stub: it rejects with aComfyError,httpStatus 400,code "error"and the server's message.CHANGELOG.md: one Fixed entry.CODE_BY_STATUS,BY_CODEand the exported classes are unchanged, and every existing envelope test passes unmodified.Judgment calls
detailsread, with the existing blank line left in place beforeif (!code). That keeps it off the lines the open #196 rewrites.git merge-treeagainst #196's head mergessrc/low/errors.tscleanly.CHANGELOG.mdandsrc/low/errors.test.tsdo conflict, but only because both PRs append at the same spot, so whichever lands second keeps both sides.typeof === "string"guard on the envelope message, so it behaves the same whether #196 lands before it or after.error.messageis empty or a non-string and that also has a non-empty top-level stringmessagenow takes the top-level one. Before this change it gotHTTP <status>(or the stringified non-string).BY_CODElookup a reviewer asked for is left to #196, which makes exactly that change on the same lines. Duplicating it here would makesrc/low/errors.tsconflict.Provenance
errors.tschange reverted, the two bare-body unit cases and thesubmit()stub case failsrc/low/errors.tsmerges cleanly; append-only conflicts inCHANGELOG.mdandsrc/low/errors.test.tssdk-parity(network),build-checknpm test; the repo runspnpm test.Residual
{message}shapes for the decoder 400, header-bind 400, BodyLimit 413 and gateway 500 rewrite come from a prior read-only investigation. Here they're only reproduced through the stub server.mainyet. This change doesn't depend on it.code: "error". Mapping 400 to a named code was deliberately left out because another in-flight change owns theCODE_BY_STATUStable.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.