{"record":{"id":"b72f44511995eeaf","repo":"linshenkx/prompt-optimizer","slug":"label-content-must-not-be-empty","errorCode":null,"errorMessage":"${label} content must not be empty.","messagePattern":"(.+?) content must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1705,"sourceCode":"        );\n      }\n    });\n  }\n\n  private validateContentBlock(\n    block: EvaluationContentBlock | undefined,\n    label: string\n  ): void {\n    if (!block) {\n      throw new EvaluationValidationError(`${label} must not be empty.`);\n    }\n    if (!block.label?.trim()) {\n      throw new EvaluationValidationError(`${label} label must not be empty.`);\n    }\n    const hasContent = !!block.content?.trim();\n    const hasMedia = this.hasBlockMedia(block);\n    if (!hasContent && !hasMedia) {\n      throw new EvaluationValidationError(`${label} content must not be empty.`);\n    }\n    if (block.media) {\n      this.validateMediaItems(block.media, `${label} media`);\n    }\n  }\n\n  private validateTestCase(testCase: EvaluationTestCase | undefined, label: string): void {\n    if (!testCase?.id?.trim()) {\n      throw new EvaluationValidationError(`${label} id must not be empty.`);\n    }\n    this.validateContentBlock(testCase.input, `${label} input`);\n  }\n\n  private validateSnapshot(snapshot: EvaluationSnapshot | undefined, label: string): void {\n    if (!snapshot?.id?.trim()) {\n      throw new EvaluationValidationError(`${label} id must not be empty.`);\n    }\n    if (!snapshot?.label?.trim()) {","sourceCodeStart":1687,"sourceCodeEnd":1723,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1687-L1723","documentation":"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.","triggerScenarios":"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.","commonSituations":"Front-end forms allowing submit with only a label; trimming content to empty before submission; media items lost during serialization so media becomes [].","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"],"exampleFix":"// before\ninput: { label: 'prompt', content: '   ' }\n\n// after\ninput: { label: 'prompt', content: 'Describe the attached image.', media: [{ label: 'img', assetId: 'img-1' }] }","handlingStrategy":"validation","validationCode":"function blockHasMaterial(block: { content?: string; media?: unknown[] }): boolean {\n  return !!block.content?.trim() || (block.media?.some(m => !!m?.assetId?.trim() || !!m?.b64?.trim()) ?? false);\n}","typeGuard":"const isNonEmptyBlock = (b: { content?: string; media?: unknown[] } | undefined): boolean =>\n  !!b?.content?.trim() || !!b?.media?.length;","tryCatchPattern":"try {\n  await evaluationService.create(request);\n} catch (err) {\n  if (err instanceof EvaluationValidationError && /content must not be empty/.test(err.message)) {\n    removeOrFillEmptyBlock(err.message);\n  } else throw err;\n}","preventionTips":["Disable submit until the block has text or at least one media item","Verify media arrays survive JSON serialization","Trim-check content client-side"],"tags":["evaluation","validation","empty-content","content-block"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}