{"record":{"id":"c7bfeb9c8845a67a","repo":"yikart/AiToEarn","slug":"reference-audio-requires-at-least-one-reference-im","errorCode":null,"errorMessage":"reference_audio requires at least one reference image or reference video","messagePattern":"reference_audio requires at least one reference image or reference video","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts","lineNumber":179,"sourceCode":"\n    if (firstFrameImages.length > 1) {\n      throw new BadRequestException('Only one first frame image is allowed')\n    }\n\n    if (lastFrameImages.length > 1) {\n      throw new BadRequestException('Only one last frame image is allowed')\n    }\n\n    if (lastFrameImages.length > 0 && firstFrameImages.length === 0) {\n      throw new BadRequestException('last_frame requires first_frame')\n    }\n\n    if (hasFrameScene && hasReferenceScene) {\n      throw new BadRequestException('first_frame/last_frame and reference media cannot be mixed')\n    }\n\n    if (referenceAudios.length > 0 && referenceImages.length === 0 && referenceVideos.length === 0) {\n      throw new BadRequestException('reference_audio requires at least one reference image or reference video')\n    }\n  }\n\n  private normalizeRequest(request: UserVolcengineGenerationRequestDto) {\n    let prompt = ''\n    let inlineResolution: string | undefined\n    let inlineRatio: string | undefined\n    let inlineDuration: number | undefined\n    let inlineSeed: number | undefined\n    let inlineWatermark: boolean | undefined\n\n    const normalizedContent = request.content.map((item) => {\n      if (item.type !== ContentType.Text) {\n        return item\n      }\n\n      const parsed = parseModelTextCommand(item.text)\n      if (!prompt && parsed.prompt) {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts#L161-L197","documentation":"Reference audio on Volcengine only works as part of a reference-based generation that also includes at least one reference image or reference video. validateContent throws this BadRequestException when reference_audio items exist but no reference image and no reference video are present.","triggerScenarios":"Content array containing only reference_audio items (with other frame-scene items absent), i.e. audio without any visual reference.","commonSituations":"Client sends a voice/ narration clip expecting audio-driven video; UI uploads audio alone; code assumed standalone audio-to-video was supported.","solutions":["Add at least one reference_image or reference_video content item alongside the audio","Remove the reference_audio if audio-driven generation is not intended","Check the current Volcengine model capabilities — standalone audio input is not accepted"],"exampleFix":"// before\ncontent: [{ type:'audio_url', role:'reference_audio', url: wav }]\n// after\ncontent: [{ type:'image_url', role:'reference_image', url: img }, { type:'audio_url', role:'reference_audio', url: wav }]","handlingStrategy":"validation","validationCode":"const hasAudio = content.some(c => c.role === 'reference_audio'); const hasVisualRef = content.some(c => c.role === 'reference_image' || c.role === 'reference_video'); if (hasAudio && !hasVisualRef) throw new Error('reference_audio requires a reference image or video')","typeGuard":"const audioHasVisualRef = (c: Content[]) => !c.some(i => i.role === 'reference_audio') || c.some(i => i.role === 'reference_image' || i.role === 'reference_video')","tryCatchPattern":"try { await generate(req) } catch (e) { if (e instanceof BadRequestException && e.message.includes('reference_audio')) { /* attach a reference image/video or drop the audio */ } else throw e }","preventionTips":["Require an image/video upload before enabling audio upload","Never send audio-only content for Volcengine video generation","Check model capability docs before adding audio inputs"],"tags":["validation","volcengine","content-constraints"],"backgroundTag":"missing-required-companion-field","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}