{"record":{"id":"1c927b7b1646e751","repo":"linshenkx/prompt-optimizer","slug":"label-index-1-label-must-not-be-empty","errorCode":null,"errorMessage":"${label} #${index + 1} label must not be empty.","messagePattern":"(.+?) #(.+?) label must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1675,"sourceCode":"\n  private hasSnapshotOutputMedia(snapshot: EvaluationSnapshot | null | undefined): boolean {\n    return this.hasBlockMedia(snapshot?.outputBlock);\n  }\n\n  private hasMediaPayload(mediaItem: EvaluationMediaItem | null | undefined): boolean {\n    const assetId = mediaItem?.assetId?.trim() || '';\n    const b64 = mediaItem?.b64?.trim() || '';\n    return !!assetId || !!b64;\n  }\n\n  private validateMediaItems(mediaItems: EvaluationMediaItem[], label: string): void {\n    mediaItems.forEach((item, index) => {\n      const itemLabel = item?.label?.trim() || '';\n      const assetId = item?.assetId?.trim() || '';\n      const b64 = item?.b64?.trim() || '';\n\n      if (!itemLabel) {\n        throw new EvaluationValidationError(`${label} #${index + 1} label must not be empty.`);\n      }\n\n      if (!assetId && !b64) {\n        throw new EvaluationValidationError(\n          `${label} #${index + 1} must provide either assetId or b64.`\n        );\n      }\n\n      if (assetId && b64) {\n        throw new EvaluationValidationError(\n          `${label} #${index + 1} must not provide both assetId and b64.`\n        );\n      }\n    });\n  }\n\n  private validateContentBlock(\n    block: EvaluationContentBlock | undefined,","sourceCodeStart":1657,"sourceCodeEnd":1693,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1657-L1693","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nmedia: [{ assetId: 'img-1' }]\n\n// after\nmedia: [{ label: 'expected output screenshot', assetId: 'img-1' }]","handlingStrategy":"validation","validationCode":"function validateMediaLabels(media: { label?: string }[]): void {\n  media.forEach((item, i) => {\n    if (!item?.label?.trim()) throw new Error(`media[${i}] is missing a label`);\n  });\n}","typeGuard":"const hasLabel = (m: { label?: string } | undefined): boolean => !!m?.label?.trim();","tryCatchPattern":"try {\n  await evaluationService.create(request);\n} catch (err) {\n  if (err instanceof EvaluationValidationError && /label must not be empty/.test(err.message)) {\n    showFieldError(err.message); // surface index from message to the user\n  } else throw err;\n}","preventionTips":["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"],"tags":["evaluation","validation","media","label"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}