linshenkx/prompt-optimizer · error · EvaluationValidationError
${label} promptText must not be empty.
Error message
${label} promptText must not be empty. What it means
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.
Source
Thrown at packages/core/src/services/evaluation/service.ts:1730
private validateTestCase(testCase: EvaluationTestCase | undefined, label: string): void {
if (!testCase?.id?.trim()) {
throw new EvaluationValidationError(`${label} id must not be empty.`);
}
this.validateContentBlock(testCase.input, `${label} input`);
}
private validateSnapshot(snapshot: EvaluationSnapshot | undefined, label: string): void {
if (!snapshot?.id?.trim()) {
throw new EvaluationValidationError(`${label} id must not be empty.`);
}
if (!snapshot?.label?.trim()) {
throw new EvaluationValidationError(`${label} label must not be empty.`);
}
if (!snapshot?.testCaseId?.trim()) {
throw new EvaluationValidationError(`${label} testCaseId must not be empty.`);
}
if (!snapshot?.promptText?.trim()) {
throw new EvaluationValidationError(`${label} promptText must not be empty.`);
}
if (!snapshot?.output?.trim()) {
throw new EvaluationValidationError(`${label} output must not be empty.`);
}
if (!snapshot?.promptRef?.kind) {
throw new EvaluationValidationError(`${label} promptRef.kind must not be empty.`);
}
if (snapshot.executionInput) {
this.validateContentBlock(snapshot.executionInput, `${label} executionInput`);
}
if (snapshot.outputBlock) {
this.validateContentBlock(snapshot.outputBlock, `${label} outputBlock`);
}
}
private normalizeContentBlock(block?: EvaluationContentBlock): NormalizedContentBlock | undefined {
const label = block?.label?.trim() || '';
const content = block?.content?.trim() || '';View on GitHub (pinned to 3e677b1d9f)
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
Example fix
// before
const snap = { label: 'l', testCaseId: 'tc1', output: 'out' };
// after
const snap = { label: 'l', testCaseId: 'tc1', promptText: renderedPrompt, output: 'out' }; Defensive patterns
Strategy: validation
Validate before calling
if (!snapshot.promptText?.trim()) throw new Error('promptText required — render your template first'); Type guard
const hasPromptText = (s: unknown): s is { promptText: string } => typeof (s as any)?.promptText === 'string' && (s as any).promptText.trim().length > 0; Prevention
- Render prompt templates and assert non-empty result before creating snapshots
- Type snapshots with a non-optional promptText: string field
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Iteration requirement must not be empty.
- Result evaluation snapshot testCaseId must match testCase.id
- Image result evaluation requires at least one output image e
- Compare evaluation requires at least one test case.
- Compare evaluation requires at least two snapshots.
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/2229b1004518809e.
Report an issue: GitHub.