{"record":{"id":"5a74d6e1f602f9d3","repo":"linshenkx/prompt-optimizer","slug":"label-id-must-not-be-empty","errorCode":null,"errorMessage":"${label} id must not be empty.","messagePattern":"(.+?) id must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1714,"sourceCode":"    if (!block) {\n      throw new EvaluationValidationError(`${label} must not be empty.`);\n    }\n    if (!block.label?.trim()) {\n      throw new EvaluationValidationError(`${label} label must not be empty.`);\n    }\n    const hasContent = !!block.content?.trim();\n    const hasMedia = this.hasBlockMedia(block);\n    if (!hasContent && !hasMedia) {\n      throw new EvaluationValidationError(`${label} content must not be empty.`);\n    }\n    if (block.media) {\n      this.validateMediaItems(block.media, `${label} media`);\n    }\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()) {","sourceCodeStart":1696,"sourceCodeEnd":1732,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1696-L1732","documentation":"Every test case in an evaluation must have a non-empty id so results can be correlated back to inputs. validateTestCase throws when testCase.id is missing or whitespace — the message includes the label passed by the caller (e.g. 'Test case #3') to identify the offending case.","triggerScenarios":"Submitting an evaluation whose testCases array contains an entry with no id, an empty id, or an id of spaces. Typically from generated or imported test case lists.","commonSituations":"CSV/JSON import where the id column is blank; array index used as id but off-by-one left it undefined; deduplication code deleting ids; id field renamed during a schema migration.","solutions":["Assign a unique non-empty string id to every test case before submission","Use the error message's label to find the exact entry and fix it","Generate ids deterministically (e.g. slug or uuid) during import if the source lacks them"],"exampleFix":"// before\ntestCases: [{ input: { label: 'p', content: 'hi' } }]\n\n// after\ntestCases: [{ id: 'tc-001', input: { label: 'p', content: 'hi' } }]","handlingStrategy":"validation","validationCode":"import { randomUUID } from 'node:crypto';\n\nfunction ensureTestCaseIds(testCases: { id?: string }[]): void {\n  testCases.forEach((tc, i) => {\n    if (!tc.id?.trim()) tc.id = `tc-${i + 1}-${randomUUID().slice(0, 8)}`;\n  });\n}","typeGuard":"const hasTestCaseId = (tc: { id?: string } | undefined): boolean => !!tc?.id?.trim();","tryCatchPattern":"try {\n  await evaluationService.create(request);\n} catch (err) {\n  if (err instanceof EvaluationValidationError && /id must not be empty/.test(err.message)) {\n    assignIdsAndRetry();\n  } else throw err;\n}","preventionTips":["Always mint ids (uuid/slug) when building test cases","Validate imported rows for a non-blank id column","Type test case id as required string"],"tags":["evaluation","validation","test-case","id"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}