{"record":{"id":"462860c44f6a2355","repo":"linshenkx/prompt-optimizer","slug":"image-storage-service-is-required-to-resolve-evalu","errorCode":null,"errorMessage":"Image storage service is required to resolve evaluation image asset \"${assetId}\".","messagePattern":"Image storage service is required to resolve evaluation image asset \"(.+?)\"\\.","errorType":"exception","errorClass":"EvaluationExecutionError","httpStatus":null,"severity":"critical","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":857,"sourceCode":"    const label = mediaItem.label?.trim() || 'image';\n    const inlineB64 = mediaItem.b64?.trim() || '';\n    const assetId = mediaItem.assetId?.trim() || '';\n\n    if (inlineB64) {\n      return {\n        b64: inlineB64,\n        mimeType: mediaItem.mimeType?.trim() || 'image/png',\n      };\n    }\n\n    if (!assetId) {\n      throw new EvaluationExecutionError(\n        `Evaluation image evidence \"${label}\" is missing both assetId and b64 data.`\n      );\n    }\n\n    if (!this.imageStorageService) {\n      throw new EvaluationExecutionError(\n        `Image storage service is required to resolve evaluation image asset \"${assetId}\".`\n      );\n    }\n\n    const storedImage = await this.imageStorageService.getImage(assetId);\n    if (!storedImage?.data?.trim()) {\n      throw new EvaluationExecutionError(\n        `Failed to resolve evaluation image asset \"${assetId}\".`\n      );\n    }\n\n    return {\n      b64: storedImage.data,\n      mimeType: mediaItem.mimeType?.trim() || storedImage.metadata?.mimeType || 'image/png',\n    };\n  }\n\n  private buildEvaluationMediaIdentity(mediaItem: EvaluationMediaItem): string {","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L839-L875","documentation":"EvaluationExecutionError thrown by resolveEvaluationMediaItem when an evidence item has an assetId but EvaluationService was constructed without an imageStorageService. Resolving stored assets requires that service; without it the asset reference cannot be dereferenced, so multimodal execution aborts.","triggerScenarios":"Evidence items reference stored images by assetId while EvaluationService lacks imageStorageService in its constructor options — common in unit tests or minimal DI setups — and an image-mode evaluation runs.","commonSituations":"DI composition updated for text-only usage and image storage omitted; test harness constructing the service with mocks but no image store; refactor dropped an optional constructor parameter; deployment profile that disabled image persistence.","solutions":["Provide an imageStorageService when constructing EvaluationService whenever assets may be referenced by id","Alternatively, embed images inline as b64 evidence so no storage service is needed","Add a startup/diagnostic check: if any configured mode is image-based, require imageStorageService"],"exampleFix":"// before\nconst svc = new EvaluationService({ modelManager, templateManager, llmService, imageUnderstandingService });\n\n// after\nconst svc = new EvaluationService({\n  modelManager, templateManager, llmService, imageUnderstandingService,\n  imageStorageService,\n});","handlingStrategy":"validation","validationCode":"const usesAssets = evidence.some(e => Boolean(e.assetId) && !e.b64);\nif (usesAssets && !imageStorageService) throw new Error('assetId evidence requires imageStorageService');","typeGuard":"const serviceSupportsAssets = (svc: EvaluationService) => Boolean((svc as any).imageStorageService);","tryCatchPattern":"try { await svc.evaluate(req); } catch (e) { if (e instanceof EvaluationExecutionError && /Image storage service/.test(e.message)) { inlineB64EvidenceAndRetry(); } else throw e; }","preventionTips":["Wire imageStorageService whenever image modes are configurable","Prefer inline b64 in tests that skip storage","Assert constructor dependencies in DI tests"],"tags":["evaluation","image","asset","dependency-injection","configuration"],"backgroundTag":"missing-service-dependency","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}