{"record":{"id":"7a043bcb6276127e","repo":"linshenkx/prompt-optimizer","slug":"image-understanding-request-cannot-be-empty","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/image-understanding/service.ts","lineNumber":42,"sourceCode":"    return await adapter.sendImageUnderstanding(runtimeRequest, request.modelConfig)\n  }\n\n  async understandStream(\n    request: ImageUnderstandingExecutionRequest,\n    callbacks: StreamHandlers\n  ) {\n    this.validateRequest(request)\n\n    const providerId = request.modelConfig.providerMeta.id\n    const adapter = this.registry.getAdapter(providerId)\n    const runtimeRequest = await this.prepareRuntimeRequest(request)\n\n    await adapter.sendImageUnderstandingStream(runtimeRequest, request.modelConfig, callbacks)\n  }\n\n  private validateRequest(request: ImageUnderstandingExecutionRequest): void {\n    if (!request || typeof request !== 'object') {\n      throw new RequestConfigError('Image understanding request cannot be empty')\n    }\n\n    const modelConfig = request.modelConfig\n    if (!modelConfig) {\n      throw new RequestConfigError('Model config cannot be empty')\n    }\n\n    if (!modelConfig.providerMeta?.id) {\n      throw new RequestConfigError('Model provider metadata cannot be empty')\n    }\n\n    if (!modelConfig.modelMeta?.id) {\n      throw new RequestConfigError('Model metadata cannot be empty')\n    }\n\n    if (!modelConfig.enabled) {\n      throw new RequestConfigError('Model is not enabled')\n    }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/image-understanding/service.ts#L24-L60","documentation":"Thrown by ImageUnderstandingService.validateRequest when the request argument is null/undefined or not an object. validateRequest runs at the top of understand/understandStream and enforces a minimal request shape before any adapter work.","triggerScenarios":"Calling understand(null), understand(undefined), or understand('prompt' as any); a variable that was expected to be built earlier but was never assigned.","commonSituations":"Optional chaining that short-circuits to undefined ({...userInput}?.request); async builders that return undefined on early exits; default parameter values missing.","solutions":["Pass a fully-formed ImageUnderstandingExecutionRequest object with at least modelConfig and inputs.","Guard at the call site: if (!request) return early instead of invoking the service.","Default the parameter: understand(request ?? buildDefaultRequest())."],"exampleFix":"// before\nawait service.understand(req ?? (null as any)) // throws\n\n// after\nif (!req) throw new Error('request missing')\nawait service.understand(req)","handlingStrategy":"validation","validationCode":"if (!request || typeof request !== 'object') {\n  throw new TypeError('request required')\n}\nawait service.understand(request)","typeGuard":"const isExecutionRequest = (r: unknown): r is ImageUnderstandingExecutionRequest =>\n  typeof r === 'object' && r !== null && 'modelConfig' in r","tryCatchPattern":null,"preventionTips":["Guard optional-built request variables before calling understand","Avoid casting null/undefined to the request type"],"tags":["validation","request","null-check"],"backgroundTag":"empty-request-body","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}