{"record":{"id":"43cb5b019e59a0f4","repo":"linshenkx/prompt-optimizer","slug":"label-promptref-kind-must-not-be-empty","errorCode":null,"errorMessage":"${label} promptRef.kind must not be empty.","messagePattern":"(.+?) promptRef\\.kind must not be empty\\.","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":1736,"sourceCode":"\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()) {\n      throw new EvaluationValidationError(`${label} label must not be empty.`);\n    }\n    if (!snapshot?.testCaseId?.trim()) {\n      throw new EvaluationValidationError(`${label} testCaseId must not be empty.`);\n    }\n    if (!snapshot?.promptText?.trim()) {\n      throw new EvaluationValidationError(`${label} promptText must not be empty.`);\n    }\n    if (!snapshot?.output?.trim()) {\n      throw new EvaluationValidationError(`${label} output must not be empty.`);\n    }\n    if (!snapshot?.promptRef?.kind) {\n      throw new EvaluationValidationError(`${label} promptRef.kind must not be empty.`);\n    }\n    if (snapshot.executionInput) {\n      this.validateContentBlock(snapshot.executionInput, `${label} executionInput`);\n    }\n    if (snapshot.outputBlock) {\n      this.validateContentBlock(snapshot.outputBlock, `${label} outputBlock`);\n    }\n  }\n\n  private normalizeContentBlock(block?: EvaluationContentBlock): NormalizedContentBlock | undefined {\n    const label = block?.label?.trim() || '';\n    const content = block?.content?.trim() || '';\n    if (!label || (!content && !this.hasBlockMedia(block))) {\n      return undefined;\n    }\n\n    const summary = block?.summary?.trim() || '';\n    return {","sourceCodeStart":1718,"sourceCodeEnd":1754,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L1718-L1754","documentation":"EvaluationValidationError thrown when snapshot.promptRef.kind is falsy. promptRef records what kind of prompt produced the run (e.g. a specific prompt/template reference) and its kind discriminator is mandatory. A missing kind makes the reference unresolvable, so validation fails.","triggerScenarios":"Providing a snapshot with promptRef omitted entirely, set to null, or an object without a kind property (or kind: '').","commonSituations":"Optional promptRef added in a newer version of the schema but old callers don't send it; constructing promptRef: { id } while forgetting kind; deserialization dropping discriminated-union fields.","solutions":["Set snapshot.promptRef = { kind: <valid kind>, ... } matching the supported prompt reference kinds","Check the PromptRef type/union in the package for the accepted kind values","Upgrade callers to the schema version that requires promptRef and regenerate types"],"exampleFix":"// before\nconst snap = { ...base, promptRef: { id: prompt.id } };\n\n// after\nconst snap = { ...base, promptRef: { kind: 'prompt', id: prompt.id } };","handlingStrategy":"validation","validationCode":"const PROMPT_REF_KINDS = ['prompt','template'] as const; // check package's PromptRef type for real values\nif (!PROMPT_REF_KINDS.includes(snapshot.promptRef?.kind)) throw new Error('promptRef.kind missing/invalid');","typeGuard":"function isPromptRef(v: unknown): v is { kind: string } { return typeof (v as any)?.kind === 'string' && (v as any).kind !== ''; }","tryCatchPattern":null,"preventionTips":["Always construct promptRef through a helper that sets kind from the PromptRef union","Keep TS types strict so missing kind fails at compile time"],"tags":["validation","evaluation","discriminated-union"],"backgroundTag":"required-field-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}