mirror of
https://github.com/Comfy-Org/comfy-typescript-sdk.git
synced 2026-11-04 23:47:27 +00:00
[PR #206] feat(errors): map sso_required to Forbidden and carry organizationId #209
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#209
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/206
Author: @mattmillerai
Created: 10/9/2026
Status: 🔄 Open
Base:
main← Head:matt/be-19943-sso-required-forbidden📝 Commits (2)
af39985feat(errors): map sso_required to Forbidden and carry organizationId345993ffix(errors): read organizationId only on sso_required, and scope the claim📊 Changes
8 files changed (+189 additions, -4 deletions)
View changed files
📝
CHANGELOG.md(+11 -0)📝
README.md(+6 -1)📝
src/low/errors.test.ts(+45 -0)📝
src/low/errors.ts(+29 -2)📝
src/sdk/client.test.ts(+25 -0)📝
src/sdk/exceptions.test.ts(+37 -0)📝
src/sdk/exceptions.ts(+17 -1)📝
test/support/stub-server.ts(+19 -0)📄 Description
ELI-5
When a personal API key belongs to an account whose organization requires single sign-on, the server refuses every call with
403 sso_requiredand names the organization. The SDK used to turn that into a generic error and drop the organization. Now it raisesForbidden(so an authcatchsees it), keepscode === "sso_required", and exposes the organization aserr.organizationId, which is the value needed to start the SSO flow.What changed
src/low/errors.ts:ApiErrorgainsorganizationId: string | null.BY_CODEmapssso_required → Forbidden.errorFromEnvelopereadserror.organization_idfrom the envelope only when the resolved code issso_required. A missing, non-string, empty or whitespace-only value becomesnull. The code lookup goes throughObject.hasOwn, so a wire code such asconstructorfalls back toApiError.src/sdk/exceptions.ts:ComfyErrorgains the sameorganizationIdfield, andBY_CODEmapssso_required → Forbidden(also looked up withObject.hasOwn).toSdkErrorforwardsorganizationIdon both branches (queue_fulland generic), so neither path can lose it.test/support/stub-server.ts: newServerState.ssoRequiredscenario. It refuses every authenticated request with403 sso_required. WhenorganizationIdisnullit omitsorganization_id, as the gateway does when it does not know the org.organization_idignored on other codes), inherited-name codes falling back to the bare class, forwarding on bothtoSdkErrorbranches, and an end-to-endcomfy.jobs.getcase against the stub server, with an org and withnull.sso_requiredin the README's typed-errors list. Both say which paths cannot surface the code: the bodilessHEADasset-dedup probe, andcomfy.models.*(Router).Judgment calls:
surface-parity.test.tspasses unchanged.ForbiddenextendsComfyError, so existingcatch (e instanceof ComfyError)code still matches.Provenance
pnpm test(801 passed, 5 skipped; the skips were already there)pnpm lint,pnpm format:check,pnpm typecheck)pnpm check:spec-drift); build: OK (pnpm build, at the original head)sso_requiredfrom the sdkBY_CODEfails 4 of the new tests, including both end-to-end stub-server casespnpm check:sdk-parity(network; this change adds no class orerror_type), the shared hygiene workflow, the Node 22/24 CI matrixorganizationIdnow reads only onsso_required; both code maps useObject.hasOwn; the docs no longer claim "every operation"Residual
comfy.models.*(Router) path is untouched. Router failures go throughrouterErrorsand are keyed onerror_type, not on the v2 envelope'scode. If the gateway also answers Router calls withsso_required, those calls do not yet surfaceorganizationId. Neither the ticket nor the vendored Router contract declares this, so it was left alone.403 sso_requiredresponse was not exercised against a live deployment. Verification is against the stub server only.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.