From 8e60ed22346c5d10a5c57da8924ad2986c0ecd77 Mon Sep 17 00:00:00 2001 From: wei-hai Date: Tue, 21 Jul 2026 18:26:35 -0700 Subject: [PATCH] fix: map entity-specific 404 codes in the high-level toSdkError too The prior fix only added job_not_found/asset_not_found to the low-level error map; the high-level toSdkError (what the client actually surfaces to callers) has its own code map that still fell through to a generic ComfyError for a missing job/asset. Add the codes there too, with a test. Co-Authored-By: Claude Opus 4.8 --- src/sdk/exceptions.test.ts | 2 ++ src/sdk/exceptions.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/sdk/exceptions.test.ts b/src/sdk/exceptions.test.ts index 48a5e00..afac242 100644 --- a/src/sdk/exceptions.test.ts +++ b/src/sdk/exceptions.test.ts @@ -27,6 +27,8 @@ describe("toSdkError", () => { ["idempotency_key_reuse", IdempotencyKeyReuse], ["insufficient_credits", InsufficientCredits], ["not_found", NotFound], + ["job_not_found", NotFound], + ["asset_not_found", NotFound], ["unauthorized", Unauthorized], ["forbidden", Forbidden], ]; diff --git a/src/sdk/exceptions.ts b/src/sdk/exceptions.ts index a012ba0..9d164ab 100644 --- a/src/sdk/exceptions.ts +++ b/src/sdk/exceptions.ts @@ -94,6 +94,11 @@ const BY_CODE: Record = { idempotency_key_reuse: IdempotencyKeyReuse, insufficient_credits: InsufficientCredits, not_found: NotFound, + // public-api returns entity-specific 404 codes even though the spec documents + // the generic not_found; map them so a missing job/asset raises the typed + // NotFound. (Server/spec reconciliation of the code set is a separate follow-up.) + job_not_found: NotFound, + asset_not_found: NotFound, unauthorized: Unauthorized, forbidden: Forbidden, };