linshenkx/prompt-optimizer · error · EvaluationValidationError
${label} content must not be empty.
Error message
${label} content must not be empty. What it means
A content block must contain actual material: either non-empty text content or at least one media attachment (checked via hasBlockMedia). This error fires when the block has a label but both content and media are absent/blank, leaving an empty shell the evaluation cannot execute.
Source
Thrown at packages/core/src/services/evaluation/service.ts:1705
);
}
});
}
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.`);
}
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()) {View on GitHub (pinned to 3e677b1d9f)
Solutions
- Populate block.content with the prompt text, or attach at least one valid media item
- If media was intended, verify the media array survived serialization and items pass validateMediaItems
- Guard submissions with a client-side emptiness check
Example fix
// before
input: { label: 'prompt', content: ' ' }
// after
input: { label: 'prompt', content: 'Describe the attached image.', media: [{ label: 'img', assetId: 'img-1' }] } Defensive patterns
Strategy: validation
Validate before calling
function blockHasMaterial(block: { content?: string; media?: unknown[] }): boolean {
return !!block.content?.trim() || (block.media?.some(m => !!m?.assetId?.trim() || !!m?.b64?.trim()) ?? false);
} Type guard
const isNonEmptyBlock = (b: { content?: string; media?: unknown[] } | undefined): boolean =>
!!b?.content?.trim() || !!b?.media?.length; Try / catch
try {
await evaluationService.create(request);
} catch (err) {
if (err instanceof EvaluationValidationError && /content must not be empty/.test(err.message)) {
removeOrFillEmptyBlock(err.message);
} else throw err;
} Prevention
- Disable submit until the block has text or at least one media item
- Verify media arrays survive JSON serialization
- Trim-check content client-side
When it happens
Trigger: A content block such as { label: 'prompt' } with no content and no media array (or media: []). Also fires when content is whitespace-only and media is empty.
Common situations: Front-end forms allowing submit with only a label; trimming content to empty before submission; media items lost during serialization so media becomes [].
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} must not be empty.
- ${label} label must not be empty.
- Unrecognized data structure
- 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/b72f44511995eeaf.
Report an issue: GitHub.