{"record":{"id":"d6afdf69f770fbb1","repo":"n8n-io/n8n","slug":"task-failed-errorcode-errormessage","errorCode":null,"errorMessage":"Task failed: [${errorCode}] ${errorMessage}","messagePattern":"Task failed: \\[(.+?)\\] (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/AlibabaCloud/transport/index.ts","lineNumber":82,"sourceCode":" * @param pollIntervalMs - Interval between polls in milliseconds. Defaults to 15 seconds.\n * @returns The final task response containing video_url on success.\n */\nexport async function pollTaskResult(\n\tthis: IExecuteFunctions,\n\ttaskId: string,\n\tpollIntervalMs: number = DEFAULT_POLL_INTERVAL_MS,\n): Promise<IDataObject> {\n\tfor (let attempt = 0; attempt < MAX_POLL_ATTEMPTS; attempt++) {\n\t\tconst response = await apiRequest.call(this, 'GET', `/api/v1/tasks/${taskId}`);\n\n\t\tconst taskStatus = response?.output?.task_status as string;\n\n\t\tif (TERMINAL_STATUSES.includes(taskStatus)) {\n\t\t\tif (taskStatus === 'FAILED') {\n\t\t\t\tconst errorCode = response?.output?.code || response?.code || 'UNKNOWN';\n\t\t\t\tconst errorMessage =\n\t\t\t\t\tresponse?.output?.message || response?.message || 'Video generation task failed';\n\t\t\t\tthrow new NodeOperationError(this.getNode(), `Task failed: [${errorCode}] ${errorMessage}`);\n\t\t\t}\n\n\t\t\tif (taskStatus === 'CANCELED') {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Video generation task was canceled');\n\t\t\t}\n\n\t\t\t// SUCCEEDED\n\t\t\treturn response as IDataObject;\n\t\t}\n\n\t\t// Wait before next poll\n\t\tawait sleep(pollIntervalMs);\n\t}\n\n\tthrow new NodeOperationError(\n\t\tthis.getNode(),\n\t\t`Task ${taskId} did not complete within the maximum polling time. Last status was not terminal. You can query the task manually using the task ID.`,\n\t);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/AlibabaCloud/transport/index.ts#L64-L100","documentation":"Thrown by pollTaskResult when the AlibabaCloud DashScope task API returns a terminal status of 'FAILED'. The polling loop checks task_status against TERMINAL_STATUSES; when it equals 'FAILED', the code extracts the error code and message from the response (checking output.code/output.message first, then top-level code/message, with 'UNKNOWN' and a generic message as fallbacks) and throws a NodeOperationError with the formatted error string.","triggerScenarios":"An asynchronous video generation task reached FAILED status on the DashScope side. This is the API reporting that the actual video generation work failed after the task was successfully created and accepted. Common causes include content policy violations during rendering, internal model errors, resource constraints, or invalid input data discovered during processing.","commonSituations":"The prompt or image content passes initial validation but is rejected during actual generation; the model encounters an internal error processing the specific input; the input image is too large or has an unsupported aspect ratio for the requested resolution; concurrent task limits exceeded.","solutions":["Read the errorCode and errorMessage in the thrown error — format is 'Task failed: [CODE] MESSAGE' which maps to DashScope's error taxonomy.","If the error is content-policy related, modify the prompt or input image to comply with Alibaba Cloud's content guidelines.","Retry the task — transient internal failures may succeed on retry.","Reduce input complexity (lower resolution, shorter duration) if the error suggests resource limits.","Check Alibaba Cloud DashScope status page for ongoing service incidents."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await pollTaskResult.call(this, taskId);\n  // ... process result ...\n} catch (error) {\n  if (error instanceof NodeOperationError && error.message.startsWith('Task failed:')) {\n    const match = error.message.match(/\\[(\\w+)] (.+)/);\n    const errorCode = match?.[1];\n    const errorMsg = match?.[2];\n    // handle based on error code, e.g. retry for transient errors\n  }\n  throw error;\n}","preventionTips":["Avoid prompts or images that may trigger content moderation filters during video rendering.","Use supported resolution/duration combinations to avoid processing failures.","Retry once for transient FAILED statuses — some failures are sporadic.","Monitor DashScope error codes in the error message to identify recurring patterns.","Keep inputs simple initially and increase complexity gradually."],"tags":["video-generation","async-task","polling","alibabacloud","dashscope"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}