{"record":{"id":"59a45ab0a19346b0","repo":"linshenkx/prompt-optimizer","slug":"result-evaluation-snapshot-testcaseid-must-match-t","errorCode":null,"errorMessage":"Result evaluation snapshot testCaseId must match testCase.id.","messagePattern":"Result evaluation snapshot testCaseId must match testCase\\.id\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":475,"sourceCode":"    if (!request.mode) {\n      throw new EvaluationValidationError('Evaluation mode configuration must not be empty.');\n    }\n    if (!request.mode.functionMode) {\n      throw new EvaluationValidationError('Function mode must not be empty.');\n    }\n    if (!request.mode.subMode) {\n      throw new EvaluationValidationError('Sub mode must not be empty.');\n    }\n\n    switch (request.type) {\n      case 'result':\n        if (!request.target?.workspacePrompt?.trim()) {\n          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        this.validateTestCase(request.testCase, 'Result evaluation test case');\n        this.validateSnapshot(request.snapshot, 'Result evaluation snapshot');\n        if (request.snapshot.testCaseId !== request.testCase.id) {\n          throw new EvaluationValidationError(\n            'Result evaluation snapshot testCaseId must match testCase.id.'\n          );\n        }\n        if (this.isImageText2ImageMode(request) && !this.hasSnapshotOutputMedia(request.snapshot)) {\n          throw new EvaluationValidationError(\n            'Image result evaluation requires at least one output image evidence item.'\n          );\n        }\n        break;\n\n      case 'compare':\n        if (!request.target?.workspacePrompt?.trim()) {\n          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        if (!Array.isArray(request.testCases) || request.testCases.length < 1) {\n          throw new EvaluationValidationError('Compare evaluation requires at least one test case.');\n        }\n        if (!Array.isArray(request.snapshots) || request.snapshots.length < 2) {","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L457-L493","documentation":"Thrown by EvaluationService.validateRequest when a 'result'-type evaluation request has a snapshot whose testCaseId does not equal the provided testCase.id. The service requires that a result evaluation evaluates exactly one snapshot belonging to exactly one test case, so the two identifiers must agree. It surfaces as EvaluationValidationError (code VALIDATION_ERROR) from evaluate/evaluateStream before any LLM call is made.","triggerScenarios":"Calling evaluate({type:'result', ...}) where request.snapshot.testCaseId !== request.testCase.id — e.g. the snapshot was captured under a different test case, or the id was regenerated/re-keyed between building testCase and snapshot.","commonSituations":"Reusing a snapshot object from a previous run while creating a fresh test case with a new id; copying fixtures and forgetting to sync the ids; frontend passing selected test case separately from the snapshot record it was generated from.","solutions":["Set snapshot.testCaseId = testCase.id before calling evaluate (they must reference the same test case)","Regenerate the snapshot for the current test case instead of reusing a stale one","Add a pre-flight assertion in your caller so mismatched ids fail fast with a clearer message"],"exampleFix":"// before\nconst res = await svc.evaluate({\n  type: 'result',\n  testCase,\n  snapshot, // snapshot.testCaseId !== testCase.id\n});\n\n// after\nconst res = await svc.evaluate({\n  type: 'result',\n  testCase,\n  snapshot: { ...snapshot, testCaseId: testCase.id },\n});","handlingStrategy":"validation","validationCode":"if (snapshot.testCaseId !== testCase.id) {\n  throw new Error(`Snapshot ${snapshot.testCaseId} does not belong to test case ${testCase.id}`);\n}\nawait svc.evaluate({ type: 'result', testCase, snapshot, ... });","typeGuard":"const isSnapshotOfCase = (s: EvaluationSnapshot, tc: EvaluationTestCase) =>\n  s.testCaseId === tc.id;","tryCatchPattern":"try { await svc.evaluate(req); } catch (e) { if (e instanceof EvaluationValidationError && e.message.includes('testCaseId')) syncIdsAndRetry(); else throw e; }","preventionTips":["Always create snapshots through an API that stamps testCaseId from the parent test case","Assert id equality in UI before enabling evaluate"],"tags":["evaluation","validation","test-case","snapshot"],"backgroundTag":"request-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}