fix(comfy): wrap malformed workflow json · openclaw/openclaw@1d46a2f
vincentkoc
·
2026-05-15
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -78,6 +78,7 @@ Docs: https://docs.openclaw.ai
|
78 | 78 | - Telnyx voice-call: use the raw `client_state` fallback when webhook state is malformed base64 instead of using silently corrupted decoded text. |
79 | 79 | - Google Meet: report malformed node-host params JSON with plugin-owned errors instead of leaking raw JSON parser failures. |
80 | 80 | - CLI/export-trajectory: report malformed encoded request JSON with a stable CLI error instead of leaking raw parser output. |
| 81 | +- ComfyUI: report malformed workflow API JSON responses with owned errors instead of leaking raw parser failures. |
81 | 82 | - Twilio voice-call: report malformed successful API JSON responses with provider-owned errors instead of leaking raw parser failures. |
82 | 83 | - Voice-call provider APIs: report malformed successful guarded JSON responses with provider-prefixed errors instead of leaking raw parser failures. |
83 | 84 | - Realtime transcription: report malformed provider websocket JSON frames with owned parser errors instead of leaking raw `SyntaxError` objects. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -201,6 +201,36 @@ describe("comfy image-generation provider", () => {
|
201 | 201 | }); |
202 | 202 | }); |
203 | 203 | |
| 204 | +it("reports malformed local workflow submit JSON as a provider error", async () => { |
| 205 | +_setComfyFetchGuardForTesting(fetchWithSsrFGuardMock); |
| 206 | +const release = vi.fn(async () => {}); |
| 207 | +fetchWithSsrFGuardMock.mockResolvedValueOnce({ |
| 208 | +response: new Response("{ nope", { |
| 209 | +status: 200, |
| 210 | +headers: { "content-type": "application/json" }, |
| 211 | +}), |
| 212 | + release, |
| 213 | +}); |
| 214 | + |
| 215 | +const provider = buildComfyImageGenerationProvider(); |
| 216 | +await expect( |
| 217 | +provider.generateImage({ |
| 218 | +provider: "comfy", |
| 219 | +model: "workflow", |
| 220 | +prompt: "draw a lobster", |
| 221 | +cfg: buildComfyConfig({ |
| 222 | +workflow: { |
| 223 | +"6": { inputs: { text: "" } }, |
| 224 | +"9": { inputs: {} }, |
| 225 | +}, |
| 226 | +promptNodeId: "6", |
| 227 | +outputNodeId: "9", |
| 228 | +}), |
| 229 | +}), |
| 230 | +).rejects.toThrow("Comfy workflow submit failed: malformed JSON response"); |
| 231 | +expect(release).toHaveBeenCalledTimes(1); |
| 232 | +}); |
| 233 | + |
204 | 234 | it("uploads reference images for local edit workflows", async () => { |
205 | 235 | _setComfyFetchGuardForTesting(fetchWithSsrFGuardMock); |
206 | 236 | fetchWithSsrFGuardMock |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -299,7 +299,11 @@ async function readJsonResponse<T>(params: {
|
299 | 299 | }); |
300 | 300 | try { |
301 | 301 | await assertOkOrThrowHttpError(response, params.errorPrefix); |
302 | | -return (await response.json()) as T; |
| 302 | +try { |
| 303 | +return (await response.json()) as T; |
| 304 | +} catch (cause) { |
| 305 | +throw new Error(`${params.errorPrefix}: malformed JSON response`, { cause }); |
| 306 | +} |
303 | 307 | } finally { |
304 | 308 | await release(); |
305 | 309 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。