{"record":{"id":"18b319810bb50c29","repo":"linshenkx/prompt-optimizer","slug":"image-compare-evaluation-requires-at-least-two-sna","errorCode":null,"errorMessage":"Image compare evaluation requires at least two snapshots with output image evidence.","messagePattern":"Image compare evaluation requires at least two snapshots with output image evidence\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":521,"sourceCode":"            );\n          }\n          testCaseIds.add(testCase.id);\n        });\n\n        request.snapshots.forEach((snapshot, index) => {\n          this.validateSnapshot(snapshot, `Compare snapshot #${index + 1}`);\n          if (!testCaseIds.has(snapshot.testCaseId)) {\n            throw new EvaluationValidationError(\n              `Compare snapshot #${index + 1} references unknown testCaseId \"${snapshot.testCaseId}\".`\n            );\n          }\n        });\n        if (this.isImageText2ImageMode(request)) {\n          const snapshotsWithMedia = request.snapshots.filter((snapshot) =>\n            this.hasSnapshotOutputMedia(snapshot)\n          );\n          if (snapshotsWithMedia.length < 2) {\n            throw new EvaluationValidationError(\n              'Image compare evaluation requires at least two snapshots with output image evidence.'\n            );\n          }\n          if (snapshotsWithMedia.length !== request.snapshots.length) {\n            throw new EvaluationValidationError(\n              'Image compare evaluation requires every compared snapshot to include output image evidence.'\n            );\n          }\n        }\n        break;\n\n      case 'prompt-only':\n        if (!request.target?.workspacePrompt?.trim()) {\n          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        break;\n\n      case 'prompt-iterate':","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L503-L539","documentation":"Thrown for compare evaluations in image text-2-image mode when fewer than two snapshots contain output image evidence. Image comparison needs at least two images to compare, so validateRequest rejects the request. Counted via hasSnapshotOutputMedia on each snapshot.","triggerScenarios":"evaluate({type:'compare', mode:<image text-2-image>, snapshots}) where 0 or 1 snapshots have output image media.","commonSituations":"Some variant runs finished text-only or failed before generating an image; snapshot evidence media lost in serialization; mixing text and image variants in one compare request in image mode.","solutions":["Ensure each compared variant snapshot includes output image evidence (assetId or b64)","Exclude snapshots lacking images from the compare set (then re-check the >=2 requirement)","Re-run the failed image generation steps before comparing"],"exampleFix":"// before\nawait svc.evaluate({ type: 'compare', mode, snapshots: [withImg, textOnly], ... });\n\n// after\nconst snaps = [snapA, snapB].map(s => ({ ...s, outputEvidence: [{ assetId: s.imageId }] }));\nawait svc.evaluate({ type: 'compare', mode, snapshots: snaps, ... });","handlingStrategy":"validation","validationCode":"const withMedia = snapshots.filter(hasSnapshotOutputMedia);\nif (isImageMode(mode) && withMedia.length < 2) throw new Error('Need >=2 snapshots with output images');\nawait svc.evaluate({ ...req, snapshots: withMedia });","typeGuard":"const hasSnapshotOutputMedia = (s: EvaluationSnapshot) =>\n  (s.outputEvidence ?? []).some(e => Boolean(e.assetId?.trim() || e.b64?.trim()));","tryCatchPattern":null,"preventionTips":["Ensure every variant produces an image before compare","Surface per-variant generation status in the UI"],"tags":["evaluation","image","compare","validation","evidence"],"backgroundTag":"missing-required-asset","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}