{"record":{"id":"cafc3a06f4d27282","repo":"linshenkx/prompt-optimizer","slug":"image-understanding-request-requires-at-least-one","errorCode":null,"errorMessage":"Image understanding request requires at least one image","messagePattern":"Image understanding request requires at least one image","errorType":"validation","errorClass":"RequestConfigError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/llm/adapters/abstract-adapter.ts","lineNumber":212,"sourceCode":"      }\n\n      if (typeof msg.content !== 'string') {\n        throw new RequestConfigError('Message content must be a string')\n      }\n    }\n  }\n\n  protected validateImageUnderstandingRequest(request: ImageUnderstandingRequest): void {\n    if (!request || typeof request !== 'object') {\n      throw new RequestConfigError('Image understanding request cannot be empty')\n    }\n\n    if (typeof request.userPrompt !== 'string' || !request.userPrompt.trim()) {\n      throw new RequestConfigError('Image understanding user prompt cannot be empty')\n    }\n\n    if (!Array.isArray(request.images) || request.images.length === 0) {\n      throw new RequestConfigError('Image understanding request requires at least one image')\n    }\n\n    request.images.forEach((image, index) => {\n      if (!image || typeof image !== 'object') {\n        throw new RequestConfigError(`Image at index ${index} is invalid`)\n      }\n\n      if (typeof image.b64 !== 'string' || !image.b64.trim()) {\n        throw new RequestConfigError(`Image at index ${index} is missing base64 data`)\n      }\n    })\n  }\n\n  // ===== 工具方法 =====\n\n  /**\n   * 处理<think>标签，分离推理内容和主要内容\n   * 从现有service.ts中的processStreamContentWithThinkTags逻辑迁移","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/llm/adapters/abstract-adapter.ts#L194-L230","documentation":"Thrown by validateImageUnderstandingRequest when request.images is missing, not an array, or an empty array. The image-understanding call needs at least one image to analyze; with none there is nothing to send. Client-side RequestConfigError raised before any network request.","triggerScenarios":"Calling sendImageUnderstanding with images: [], images: undefined, or images set to a single object instead of an array of objects.","commonSituations":"Upstream attachment step failed or user attached no file but the call proceeds anyway; images built via filter() that removed all invalid entries; passing a single image object rather than an array.","solutions":["Skip or short-circuit the API call when no images were successfully collected","Wrap a single image in an array: images: [image]","Validate Array.isArray(images) && images.length > 0 before calling"],"exampleFix":"// before\nawait adapter.sendImageUnderstanding({ userPrompt, images: [] })\n\n// after\nawait adapter.sendImageUnderstanding({ userPrompt, images: [{ b64 }] })","handlingStrategy":"validation","validationCode":"if (!Array.isArray(request.images) || request.images.length === 0) {\n  // skip the call or notify the user instead of hitting the API\n  return\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Only call sendImageUnderstanding after at least one upload succeeds","Wrap single images in an array"],"tags":["validation","image-understanding","empty-array"],"backgroundTag":"missing-image-input","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}