fix(deepinfra): wrap malformed video json · openclaw/openclaw@9f99464
vincentkoc
·
2026-05-15
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -79,6 +79,7 @@ Docs: https://docs.openclaw.ai
|
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 | 81 | - ComfyUI: report malformed workflow API JSON responses with owned errors instead of leaking raw parser failures. |
| 82 | +- DeepInfra video: report malformed successful API JSON responses with provider-owned errors instead of leaking raw parser failures. |
82 | 83 | - Twilio voice-call: report malformed successful API JSON responses with provider-owned errors instead of leaking raw parser failures. |
83 | 84 | - Voice-call provider APIs: report malformed successful guarded JSON responses with provider-prefixed errors instead of leaking raw parser failures. |
84 | 85 | - 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 |
|---|
@@ -112,6 +112,29 @@ describe("deepinfra video generation provider", () => {
|
112 | 112 | expect(release).toHaveBeenCalledOnce(); |
113 | 113 | }); |
114 | 114 | |
| 115 | +it("reports malformed native video JSON as a provider error", async () => { |
| 116 | +const release = vi.fn(async () => {}); |
| 117 | +postJsonRequestMock.mockResolvedValue({ |
| 118 | +response: { |
| 119 | +json: async () => { |
| 120 | +throw new SyntaxError("Unexpected token"); |
| 121 | +}, |
| 122 | +}, |
| 123 | + release, |
| 124 | +}); |
| 125 | + |
| 126 | +const provider = buildDeepInfraVideoGenerationProvider(); |
| 127 | +await expect( |
| 128 | +provider.generateVideo({ |
| 129 | +provider: "deepinfra", |
| 130 | +model: "deepinfra/Pixverse/Pixverse-T2V", |
| 131 | +prompt: "A bicycle weaving through a rainy neon street", |
| 132 | +cfg: {}, |
| 133 | +}), |
| 134 | +).rejects.toThrow("DeepInfra video generation failed: malformed JSON response"); |
| 135 | +expect(release).toHaveBeenCalledOnce(); |
| 136 | +}); |
| 137 | + |
115 | 138 | it("names base64 WebM data URL outputs from the MIME type", async () => { |
116 | 139 | postJsonRequestMock.mockResolvedValue({ |
117 | 140 | response: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -229,7 +229,12 @@ export function buildDeepInfraVideoGenerationProvider(): VideoGenerationProvider
|
229 | 229 | }); |
230 | 230 | try { |
231 | 231 | await assertOkOrThrowHttpError(response, "DeepInfra video generation failed"); |
232 | | -const payload = (await response.json()) as DeepInfraVideoResponse; |
| 232 | +let payload: DeepInfraVideoResponse; |
| 233 | +try { |
| 234 | +payload = (await response.json()) as DeepInfraVideoResponse; |
| 235 | +} catch (cause) { |
| 236 | +throw new Error("DeepInfra video generation failed: malformed JSON response", { cause }); |
| 237 | +} |
233 | 238 | const failed = failureMessage(payload); |
234 | 239 | if (failed) { |
235 | 240 | throw new Error(failed); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。