{"record":{"id":"010005c6b42f1b80","repo":"SillyTavern/SillyTavern","slug":"video-generation-failed-010005","errorCode":null,"errorMessage":"Video generation failed","messagePattern":"Video generation failed","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/endpoints/stable-diffusion.js","lineNumber":2022,"sourceCode":"                method: 'GET',\n                headers: {\n                    'Authorization': `Bearer ${key}`,\n                },\n            });\n\n            if (!pollResponse.ok) {\n                const text = await pollResponse.text();\n                console.warn('Z.AI video job polling failed', pollResponse.statusText, text);\n                return response.status(500).send(text);\n            }\n\n            /** @type {any} */\n            const pollResult = await pollResponse.json();\n            console.debug(`Z.AI video job status: ${pollResult.task_status}`);\n\n            if (pollResult.task_status === 'FAIL') {\n                console.warn('Z.AI video generation failed', pollResult);\n                return response.status(500).send('Video generation failed');\n            }\n\n            if (pollResult.task_status === 'SUCCESS') {\n                console.debug('Z.AI video generation succeeded', pollResult);\n                const url = pollResult?.video_result?.[0]?.url;\n\n                if (!url || !isValidUrl(url)) {\n                    console.warn('Z.AI returned an invalid video URL.');\n                    return response.sendStatus(500);\n                }\n\n                const contentResponse = await fetch(url);\n                if (!contentResponse.ok) {\n                    const text = await contentResponse.text();\n                    console.warn('Z.AI video content fetch failed', contentResponse.statusText, text);\n                    return response.status(500).send(text);\n                }\n","sourceCodeStart":2004,"sourceCodeEnd":2040,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/src/endpoints/stable-diffusion.js#L2004-L2040","documentation":"Returned (HTTP 500) when the Z.AI async-result poll returns pollResult.task_status === 'FAIL'. The upstream Z.AI job was accepted but later reported failure; the server logs the full pollResult via console.warn and sends the generic string 'Video generation failed'. The real failure reason lives in the logged pollResult, not in the response body.","triggerScenarios":"The GET to https://api.z.ai/api/paas/v4/async-result/<id> succeeds (HTTP 200) but the JSON body has task_status 'FAIL'. Common upstream causes: content-policy/NSFW rejection, prompt too long, unsupported resolution/aspect_ratio, model overload, or quota exhaustion after submission.","commonSituations":"Prompt triggers Z.AI safety filter; requested size/aspect_ratio unsupported by the video model; account balance hit zero mid-job; transient upstream GPU failure; quality param incompatible with chosen model.","solutions":["Read the server console: the console.warn('Z.AI video generation failed', pollResult) line contains the upstream failure detail — match its error code/message.","Simplify the prompt (remove policy-sensitive terms) and retry.","Reduce requested size/aspect_ratio/quality to values the video model supports.","Verify Z.AI account quota/balance and API key validity.","Retry with a different seed; FAIL can be transient under load."],"exampleFix":"// before\nif (pollResult.task_status === 'FAIL') {\n    console.warn('Z.AI video generation failed', pollResult);\n    return response.status(500).send('Video generation failed');\n}\n// after\nif (pollResult.task_status === 'FAIL') {\n    console.warn('Z.AI video generation failed', pollResult);\n    return response.status(500).send(pollResult?.error?.message || 'Video generation failed');\n}","handlingStrategy":"retry","validationCode":"// Validate request shape before sending to reduce upstream FAIL causes\nconst validSizes = ['480p','720p','1080p'];\nif (!payload.model || !validSizes.includes(payload.quality)) {\n    throw new Error('Invalid video request parameters');\n}","typeGuard":null,"tryCatchPattern":"// Retry once on FAIL — it can be transient under upstream load\nfor (let attempt = 0; attempt < 2; attempt++) {\n    const r = await fetch('/api/stable-diffusion/zai/video', opts);\n    const body = await r.text();\n    if (r.ok) break;\n    if (body.includes('Video generation failed') && attempt === 0) continue;\n    throw new Error(body);\n}","preventionTips":["Keep prompts within policy and model length limits.","Use only documented size/aspect_ratio/quality values for the video model.","Watch the server console (pollResult) for the upstream failure code before retrying blindly.","Confirm Z.AI quota/balance before retrying a FAIL that may be quota-related."],"tags":["video-generation","zai","upstream-failure","polling"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}