linshenkx/prompt-optimizer · error · EvaluationValidationError
${label} #${index + 1} label must not be empty.
Error message
${label} #${index + 1} label must not be empty. What it means
Part of evaluation input validation: every media item in an evaluation's content block must carry a non-empty label. The service iterates mediaItems and throws EvaluationValidationError when item.label is missing or whitespace, including the 1-based index of the offending item in the message.
Source
Thrown at packages/core/src/services/evaluation/service.ts:1675
private hasSnapshotOutputMedia(snapshot: EvaluationSnapshot | null | undefined): boolean {
return this.hasBlockMedia(snapshot?.outputBlock);
}
private hasMediaPayload(mediaItem: EvaluationMediaItem | null | undefined): boolean {
const assetId = mediaItem?.assetId?.trim() || '';
const b64 = mediaItem?.b64?.trim() || '';
return !!assetId || !!b64;
}
private validateMediaItems(mediaItems: EvaluationMediaItem[], label: string): void {
mediaItems.forEach((item, index) => {
const itemLabel = item?.label?.trim() || '';
const assetId = item?.assetId?.trim() || '';
const b64 = item?.b64?.trim() || '';
if (!itemLabel) {
throw new EvaluationValidationError(`${label} #${index + 1} label must not be empty.`);
}
if (!assetId && !b64) {
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,View on GitHub (pinned to 3e677b1d9f)
Solutions
- Set a unique non-empty label on every media item in the media array
- Inspect the error message: it names the offending item by index — fix that exact entry
- Add a client-side check over media arrays before submit (see validation snippet)
Example fix
// before
media: [{ assetId: 'img-1' }]
// after
media: [{ label: 'expected output screenshot', assetId: 'img-1' }] Defensive patterns
Strategy: validation
Validate before calling
function validateMediaLabels(media: { label?: string }[]): void {
media.forEach((item, i) => {
if (!item?.label?.trim()) throw new Error(`media[${i}] is missing a label`);
});
} Type guard
const hasLabel = (m: { label?: string } | undefined): boolean => !!m?.label?.trim(); Try / catch
try {
await evaluationService.create(request);
} catch (err) {
if (err instanceof EvaluationValidationError && /label must not be empty/.test(err.message)) {
showFieldError(err.message); // surface index from message to the user
} else throw err;
} Prevention
- Make label required in your form/UI for every media item
- Run a client-side loop over media arrays before submit
- Include labels when generating media items programmatically
When it happens
Trigger: Submitting an evaluation (or snapshot/test case) whose input content block includes a media array where one of the items has label: '', label omitted, or a whitespace-only string. The message embeds the block label (e.g. 'Test case #2 input media') and the item index.
Common situations: Generating media items programmatically and forgetting to set label; parsing media from CSV/JSON where the label column is empty; trimming/copying sample payloads and dropping the label field.
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} #${index + 1} must not provide both assetId and b64
- ${label} label 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/1c927b7b1646e751.
Report an issue: GitHub.