{"record":{"id":"2229b1004518809e","repo":"linshenkx/prompt-optimizer","slug":"label-prompttext-must-not-be-empty","errorCode":null,"errorMessage":"${label} promptText must not be empty.","messagePattern":"(.+?) promptText must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1730,"sourceCode":"  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\n  private normalizeContentBlock(block?: EvaluationContentBlock): NormalizedContentBlock | undefined {\n    const label = block?.label?.trim() || '';\n    const content = block?.content?.trim() || '';","sourceCodeStart":1712,"sourceCodeEnd":1748,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1712-L1748","documentation":"EvaluationValidationError thrown when a snapshot's promptText is missing or blank. promptText captures the exact prompt sent to the model and is required so evaluations are reproducible and auditable. Empty prompt text means the evaluation run cannot be traced back to its input.","triggerScenarios":"Passing a snapshot to EvaluationService where snapshot.promptText is undefined/null/empty/whitespace-only, typically when the prompt was stored elsewhere or the field name was mistyped.","commonSituations":"Migrating from an older schema that used 'prompt' instead of 'promptText'; snapshots built from chat histories where the user message was empty; templating bugs producing empty rendered prompts.","solutions":["Ensure snapshot.promptText contains the final rendered prompt string (trim it first)","If the prompt lives in promptRef only, still copy its resolved text into promptText before submission","Validate snapshots with a shared schema before calling the service"],"exampleFix":"// before\nconst snap = { label: 'l', testCaseId: 'tc1', output: 'out' };\n\n// after\nconst snap = { label: 'l', testCaseId: 'tc1', promptText: renderedPrompt, output: 'out' };","handlingStrategy":"validation","validationCode":"if (!snapshot.promptText?.trim()) throw new Error('promptText required — render your template first');","typeGuard":"const hasPromptText = (s: unknown): s is { promptText: string } => typeof (s as any)?.promptText === 'string' && (s as any).promptText.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Render prompt templates and assert non-empty result before creating snapshots","Type snapshots with a non-optional promptText: string field"],"tags":["validation","evaluation","prompt"],"backgroundTag":"required-field-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}