{"record":{"id":"abbf92a2aae3146c","repo":"linshenkx/prompt-optimizer","slug":"label-must-not-be-empty","errorCode":null,"errorMessage":"${label} must not be empty.","messagePattern":"(.+?) must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1697,"sourceCode":"        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,\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    }","sourceCodeStart":1679,"sourceCodeEnd":1715,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1679-L1715","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst testCase = { id: 'tc-1' };\n\n// after\nconst testCase = {\n  id: 'tc-1',\n  input: { label: 'prompt', content: 'Summarize this text' }\n};","handlingStrategy":"type-guard","validationCode":"if (!testCase.input) throw new Error(`testCase ${testCase.id} has no input block`);","typeGuard":"const hasInput = (tc: { input?: unknown }): boolean => !!tc.input && typeof tc.input === 'object';","tryCatchPattern":"try {\n  await evaluationService.create(request);\n} catch (err) {\n  if (err instanceof EvaluationValidationError && /must not be empty/.test(err.message)) {\n    highlightMissingBlock(err.message);\n  } else throw err;\n}","preventionTips":["Make input a required field in your DTO types (no '?')","Assert payload completeness before calling the API","Beware optional chaining silently producing undefined inputs"],"tags":["evaluation","validation","content-block","missing-field"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}