{"record":{"id":"64ac9f006f43ade1","repo":"yikart/AiToEarn","slug":"canvas-not-provided-and-failed-to-retrieve-video-d","errorCode":null,"errorMessage":"Canvas not provided and failed to retrieve video dimensions for vid://${vid}. Please provide Canvas dimensions explicitly.","messagePattern":"Canvas not provided and failed to retrieve video dimensions for vid://(.+?)\\. Please provide Canvas dimensions explicitly\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/volcengine/video-edit.mcp.ts","lineNumber":62,"sourceCode":"      for (const element of layer) {\n        if (element.Type === 'video' && element.Source?.startsWith('vid://')) {\n          vid = element.Source.replace('vid://', '')\n          break\n        }\n      }\n      if (vid)\n        break\n    }\n\n    if (!vid) {\n      throw new Error('Canvas not provided and no vid:// video source found in Track. Please provide Canvas dimensions or use vid:// video sources.')\n    }\n\n    const mediaInfos = await this.volcengineService.getMediaInfos({ Vids: vid })\n    const sourceInfo = mediaInfos.MediaInfoList?.[0]?.SourceInfo\n\n    if (!sourceInfo?.Width || !sourceInfo?.Height) {\n      throw new Error(`Canvas not provided and failed to retrieve video dimensions for vid://${vid}. Please provide Canvas dimensions explicitly.`)\n    }\n\n    return { Width: sourceInfo.Width, Height: sourceInfo.Height }\n  }\n\n  /**\n   * 提交视频编辑任务（直接使用 Track 结构）\n   */\n  createSubmitDirectEditTaskTool(userId: string, userType: UserType) {\n    return wrapTool(\n      this.logger,\n      VideoEditToolName.SubmitDirectEditTask,\n      `Submit a video editing task using Volcengine Track structure.\n\n**CRITICAL - ALL PosX/PosY Rules**:\n- ALL PosX/PosY values are TOP-LEFT corner coordinates, NOT center point\n- This applies to: transform, crop, delogo, and any other filter with PosX/PosY\n- For full-screen video: ALWAYS use PosX: 0, PosY: 0","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/volcengine/video-edit.mcp.ts#L44-L80","documentation":"uploadVideo requires accountId (body field) and an uploaded file (multipart). If either is missing the controller throws BadRequestException('accountId和视频文件是必须的'). accountId resolves the access token; the file buffer is the video to upload.","triggerScenarios":"POST multipart to the upload route without the accountId form field, without a file part (field name expected by @UploadedFile, typically 'file'), or with a JSON content type instead of multipart/form-data.","commonSituations":"Client appends only the file to FormData but forgets form.append('accountId', id), the file input was left empty, or an interceptor forces Content-Type: application/json breaking multer parsing.","solutions":["Send multipart/form-data containing both a 'file' part and an 'accountId' field.","Do not set Content-Type manually — let the HTTP client set the multipart boundary.","Verify the file input has a selected file before submitting."],"exampleFix":"// before\nconst fd = new FormData();\nfd.append('file', videoFile);\nawait api.post('/plat/tiktok/upload', fd);\n// after\nconst fd = new FormData();\nfd.append('file', videoFile);\nfd.append('accountId', accountId);\nawait api.post('/plat/tiktok/upload', fd);","handlingStrategy":"validation","validationCode":"if (!accountId || !videoFile) throw new Error('accountId和视频文件是必须的');\nconst fd = new FormData();\nfd.append('accountId', accountId);\nfd.append('file', videoFile);","typeGuard":"function canUpload(accountId: unknown, file: unknown): accountId is string {\n  return typeof accountId === 'string' && accountId.length > 0 && !!file && typeof (file as File).size === 'number';\n}","tryCatchPattern":"try {\n  return await api.post('/plat/tiktok/upload', fd);\n} catch (e) {\n  if (e.response?.status === 400) console.error('上传请求缺少accountId或文件，检查FormData字段');\n  throw e;\n}","preventionTips":["Append both 'file' and 'accountId' parts to FormData","Never manually set Content-Type on multipart requests","Check file input validity (file selected, size > 0) before submit"],"tags":["validation","multipart","file-upload","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}