{"record":{"id":"8dde4af60707f48b","repo":"linshenkx/prompt-optimizer","slug":"label-testcaseid-must-not-be-empty","errorCode":null,"errorMessage":"${label} testCaseId must not be empty.","messagePattern":"(.+?) testCaseId must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1727,"sourceCode":"    }\n  }\n\n  private validateTestCase(testCase: EvaluationTestCase | undefined, label: string): void {\n    if (!testCase?.id?.trim()) {\n      throw new EvaluationValidationError(`${label} id must not be empty.`);\n    }\n    this.validateContentBlock(testCase.input, `${label} input`);\n  }\n\n  private validateSnapshot(snapshot: EvaluationSnapshot | undefined, label: string): void {\n    if (!snapshot?.id?.trim()) {\n      throw new EvaluationValidationError(`${label} id must not be empty.`);\n    }\n    if (!snapshot?.label?.trim()) {\n      throw new EvaluationValidationError(`${label} label must not be empty.`);\n    }\n    if (!snapshot?.testCaseId?.trim()) {\n      throw new EvaluationValidationError(`${label} testCaseId must not be empty.`);\n    }\n    if (!snapshot?.promptText?.trim()) {\n      throw new EvaluationValidationError(`${label} promptText must not be empty.`);\n    }\n    if (!snapshot?.output?.trim()) {\n      throw new EvaluationValidationError(`${label} output must not be empty.`);\n    }\n    if (!snapshot?.promptRef?.kind) {\n      throw new EvaluationValidationError(`${label} promptRef.kind must not be empty.`);\n    }\n    if (snapshot.executionInput) {\n      this.validateContentBlock(snapshot.executionInput, `${label} executionInput`);\n    }\n    if (snapshot.outputBlock) {\n      this.validateContentBlock(snapshot.outputBlock, `${label} outputBlock`);\n    }\n  }\n","sourceCodeStart":1709,"sourceCodeEnd":1745,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1709-L1745","documentation":"Thrown by EvaluationService when validating an evaluation snapshot whose testCaseId is missing or whitespace-only. It is part of a chain of required-field checks on snapshot objects before an evaluation can be created or executed. The error is an EvaluationValidationError, meaning caller-supplied input failed validation rather than an internal failure.","triggerScenarios":"Calling an EvaluationService API that validates snapshots (e.g. createEvaluation / run evaluation with testCase snapshots) where snapshot.testCaseId is undefined, empty string, or only whitespace after trim().","commonSituations":"Building snapshots from loose JSON payloads or CSV imports where the test-case id column is absent; renaming fields (case_id vs testCaseId) after a model/type change; constructing snapshots programmatically and forgetting to propagate the parent test case id.","solutions":["Set snapshot.testCaseId to a non-empty, trimmed string identifier of the test case","Log the offending snapshot before calling the service to spot missing fields early","Add a runtime schema check (e.g. zod) on incoming payload shapes before calling EvaluationService"],"exampleFix":"// before\nconst snapshot = { label: 'case A', promptText: '...', output: '...' };\nawait svc.createEvaluation({ ...snapshot });\n\n// after\nconst snapshot = { label: 'case A', testCaseId: testCase.id, promptText: '...', output: '...' };\nawait svc.createEvaluation({ ...snapshot });","handlingStrategy":"validation","validationCode":"function hasSnapshotRequiredFields(s: any): boolean {\n  return Boolean(s?.testCaseId?.trim()) && Boolean(s?.label?.trim()) && Boolean(s?.promptText?.trim()) && Boolean(s?.output?.trim());\n}\nconst invalid = snapshots.filter(s => !hasSnapshotRequiredFields(s));\nif (invalid.length) throw new Error(`Missing required snapshot fields on ${invalid.length} items`);","typeGuard":"function isEvaluableSnapshot(s: unknown): s is { testCaseId: string; label: string; promptText: string; output: string; promptRef: { kind: string } } {\n  const v = s as any;\n  return typeof v?.testCaseId === 'string' && v.testCaseId.trim() !== ''\n    && typeof v?.label === 'string' && v.label.trim() !== ''\n    && typeof v?.promptText === 'string' && v.promptText.trim() !== ''\n    && typeof v?.output === 'string' && v.output.trim() !== ''\n    && typeof v?.promptRef?.kind === 'string' && v.promptRef.kind !== '';\n}","tryCatchPattern":"try { await svc.createEvaluation(req); } catch (e) { if (e instanceof EvaluationValidationError) { /* fix input fields, report to user */ } else throw e; }","preventionTips":["Trim and assert all required snapshot fields at construction time","Use zod/DTO schemas on external input before it reaches the evaluation service","Centralize snapshot building in one factory function that always sets testCaseId/label/promptText/output/promptRef.kind"],"tags":["validation","evaluation","required-field"],"backgroundTag":"required-field-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}