{"record":{"id":"4023b1760cd882d4","repo":"yikart/AiToEarn","slug":"content-is-required","errorCode":null,"errorMessage":"content is required","messagePattern":"content is required","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts","lineNumber":146,"sourceCode":"  private buildSafetyIdentifier(userId: string, userType: UserType): string {\n    return `${userType}:${userId}`\n  }\n\n  private getFailureMessage(status: VolcTaskStatus, callbackData: VolcengineCallbackDto): string | undefined {\n    if (status === VolcTaskStatus.Failed) {\n      return callbackData.error?.message || 'Volcengine task failed'\n    }\n\n    if (status === VolcTaskStatus.Expired) {\n      return callbackData.error?.message || 'Volcengine task expired'\n    }\n\n    return undefined\n  }\n\n  private validateContent(content: Content[]) {\n    if (content.length === 0) {\n      throw new BadRequestException('content is required')\n    }\n\n    const imageContents = content.filter((item): item is Extract<Content, { type: ContentType.ImageUrl }> => item.type === ContentType.ImageUrl)\n    const videoContents = content.filter((item): item is Extract<Content, { type: ContentType.VideoUrl }> => item.type === ContentType.VideoUrl)\n    const audioContents = content.filter((item): item is Extract<Content, { type: ContentType.AudioUrl }> => item.type === ContentType.AudioUrl)\n\n    const firstFrameImages = imageContents.filter(item => !item.role || item.role === ImageRole.FirstFrame)\n    const lastFrameImages = imageContents.filter(item => item.role === ImageRole.LastFrame)\n    const referenceImages = imageContents.filter(item => item.role === ImageRole.ReferenceImage)\n    const referenceVideos = videoContents.filter(item => item.role === VideoRole.ReferenceVideo)\n    const referenceAudios = audioContents.filter(item => item.role === AudioRole.ReferenceAudio)\n\n    const hasFrameScene = firstFrameImages.length > 0 || lastFrameImages.length > 0\n    const hasReferenceScene = referenceImages.length > 0 || referenceVideos.length > 0 || referenceAudios.length > 0\n\n    if (firstFrameImages.length > 1) {\n      throw new BadRequestException('Only one first frame image is allowed')\n    }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts#L128-L164","documentation":"validateContent in volcengine.service.ts throws this BadRequestException when the content array of a Volcengine video generation request is empty. The Volcengine API requires at least one content item (text or media) to build a generation request, so normalizeRequest rejects the request before it reaches the provider.","triggerScenarios":"Calling the Volcengine video generation endpoint with content: [] or omitting all content items in UserVolcengineGenerationRequestDto.","commonSituations":"Clients sending only optional fields (return_last_frame, resolution) without prompt or media; frontend forms that allow submitting with no image and empty prompt; broken serialization dropping content.","solutions":["Add at least one content item (a text prompt or an image/video/audio URL) to the request","Check the client code that builds the content array — ensure it pushes items before sending","Validate content.length > 0 on the client before calling the API"],"exampleFix":"// before\nawait api.generate({ model: 'doubao-seedance', content: [] })\n// after\nawait api.generate({ model: 'doubao-seedance', content: [{ type: 'text', text: 'a cat running' }] })","handlingStrategy":"validation","validationCode":"if (!Array.isArray(content) || content.length === 0) throw new Error('content is required: add at least one text or media content item')","typeGuard":"const hasContent = (c: unknown): c is Content[] => Array.isArray(c) && c.length > 0","tryCatchPattern":"try { await generate(req) } catch (e) { if (e instanceof BadRequestException && e.message === 'content is required') { /* prompt user to add content */ } else throw e }","preventionTips":["Always include at least one text content item in generation requests","Validate the content array length in the client form before submit","Disable the submit button while content is empty"],"tags":["validation","bad-request","volcengine"],"backgroundTag":"empty-required-field","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}