linshenkx/prompt-optimizer · error · EvaluationValidationError
${label} must not be empty.
Error message
${label} must not be empty. What it means
validateContentBlock requires every evaluation content block (e.g. a test case input) to be present. This variant fires when the block itself is undefined/null — not just empty text — so the evaluation payload is structurally incomplete.
Source
Thrown at packages/core/src/services/evaluation/service.ts:1697
throw new EvaluationValidationError(
`${label} #${index + 1} must provide either assetId or b64.`
);
}
if (assetId && b64) {
throw new EvaluationValidationError(
`${label} #${index + 1} must not provide both assetId and b64.`
);
}
});
}
private validateContentBlock(
block: EvaluationContentBlock | undefined,
label: string
): void {
if (!block) {
throw new EvaluationValidationError(`${label} must not be empty.`);
}
if (!block.label?.trim()) {
throw new EvaluationValidationError(`${label} label must not be empty.`);
}
const hasContent = !!block.content?.trim();
const hasMedia = this.hasBlockMedia(block);
if (!hasContent && !hasMedia) {
throw new EvaluationValidationError(`${label} content must not be empty.`);
}
if (block.media) {
this.validateMediaItems(block.media, `${label} media`);
}
}
private validateTestCase(testCase: EvaluationTestCase | undefined, label: string): void {
if (!testCase?.id?.trim()) {
throw new EvaluationValidationError(`${label} id must not be empty.`);
}View on GitHub (pinned to 3e677b1d9f)
Solutions
- Provide the required input content block object for the entity named in the error message
- Check where the payload is assembled and assert input exists before submit
- If input is genuinely optional in your domain, gate the whole evaluation submission on its presence
Example fix
// before
const testCase = { id: 'tc-1' };
// after
const testCase = {
id: 'tc-1',
input: { label: 'prompt', content: 'Summarize this text' }
}; Defensive patterns
Strategy: type-guard
Validate before calling
if (!testCase.input) throw new Error(`testCase ${testCase.id} has no input block`); Type guard
const hasInput = (tc: { input?: unknown }): boolean => !!tc.input && typeof tc.input === 'object'; Try / catch
try {
await evaluationService.create(request);
} catch (err) {
if (err instanceof EvaluationValidationError && /must not be empty/.test(err.message)) {
highlightMissingBlock(err.message);
} else throw err;
} Prevention
- Make input a required field in your DTO types (no '?')
- Assert payload completeness before calling the API
- Beware optional chaining silently producing undefined inputs
When it happens
Trigger: Submitting a test case (or similar entity) whose input field is omitted or explicitly undefined. Validation is reached with block === undefined, e.g. { id: 'tc-1' } with no input.
Common situations: Optional chaining hiding a missing input when constructing payloads; deserializing JSON where input was dropped; schema changes making input optional when the service still requires it.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- ${label} #${index + 1} must provide either assetId or b64.
- ${label} label must not be empty.
- ${label} content must not be empty.
- Result evaluation snapshot testCaseId must match testCase.id
- Image result evaluation requires at least one output image e
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/abbf92a2aae3146c.
Report an issue: GitHub.