{"record":{"id":"46b002ab66655cc1","repo":"linshenkx/prompt-optimizer","slug":"image-understanding-request-cannot-be-empty-46b002","errorCode":null,"errorMessage":"Image understanding request cannot be empty","messagePattern":"Image understanding request cannot be empty","errorType":"validation","errorClass":"RequestConfigError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/llm/adapters/abstract-adapter.ts","lineNumber":204,"sourceCode":"\n    for (const msg of messages) {\n      if (!msg.role || !msg.content) {\n        throw new RequestConfigError('Each message must have role and content')\n      }\n\n      if (!['system', 'user', 'assistant', 'tool'].includes(msg.role)) {\n        throw new RequestConfigError(`Invalid message role: ${msg.role}`)\n      }\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      }","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/llm/adapters/abstract-adapter.ts#L186-L222","documentation":"Thrown by validateImageUnderstandingRequest when the request argument to sendImageUnderstanding / sendImageUnderstandingStream is null, undefined, or not an object. The adapter validates the request envelope before touching the network; a missing request means the call cannot proceed. Client-side RequestConfigError.","triggerScenarios":"Calling sendImageUnderstanding(null), sendImageUnderstanding(undefined), or passing a primitive (string/number) instead of an ImageUnderstandingRequest object.","commonSituations":"Optional chaining that yields undefined (req?.imageRequest); passing a base64 string directly instead of wrapping it in a request object; default parameter of undefined when config loading fails.","solutions":["Pass a proper ImageUnderstandingRequest object: { userPrompt, images: [{ b64 }] }","Check for undefined with a guard before invoking when the request comes from optional config","Log the request payload right before the call to spot null/undefined early"],"exampleFix":"// before\nawait adapter.sendImageUnderstanding(base64String as any)\n\n// after\nawait adapter.sendImageUnderstanding({ userPrompt: 'Describe this', images: [{ b64: base64String }] })","handlingStrategy":"type-guard","validationCode":"if (!request || typeof request !== 'object') throw new Error('request missing')","typeGuard":"function isImageUnderstandingRequest(r: unknown): r is ImageUnderstandingRequest {\n  return !!r && typeof r === 'object'\n    && typeof (r as ImageUnderstandingRequest).userPrompt === 'string'\n    && Array.isArray((r as ImageUnderstandingRequest).images)\n}","tryCatchPattern":"null","preventionTips":["Construct the request object inline at the call site","Avoid optional-chained config objects that can silently be undefined"],"tags":["validation","image-understanding","null-argument"],"backgroundTag":"request-object-validation","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}