{"record":{"id":"2c710d93d3b07852","repo":"linshenkx/prompt-optimizer","slug":"unknown-evaluation-type-request-as-any-type","errorCode":null,"errorMessage":"Unknown evaluation type: ${(request as any).type}","messagePattern":"Unknown evaluation type: (.+?)","errorType":"validation","errorClass":"EvaluationValidationError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":549,"sourceCode":"        break;\n\n      case 'prompt-only':\n        if (!request.target?.workspacePrompt?.trim()) {\n          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        break;\n\n      case 'prompt-iterate':\n        if (!request.target?.workspacePrompt?.trim()) {\n          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        if (!request.iterateRequirement?.trim()) {\n          throw new EvaluationValidationError('Iteration requirement must not be empty.');\n        }\n        break;\n\n      default:\n        throw new EvaluationValidationError(`Unknown evaluation type: ${(request as any).type}`);\n    }\n  }\n\n  /**\n   * 验证评估模型\n   */\n  private async validateModel(modelKey: string): Promise<TextModelConfig> {\n    const model = await this.modelManager.getModel(modelKey);\n    if (!model) {\n      throw new EvaluationModelError(modelKey);\n    }\n    return model;\n  }\n\n  /**\n   * 获取评估模板\n   */\n  private async getEvaluationTemplate(type: EvaluationType, mode: EvaluationModeConfig): Promise<Template> {","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L531-L567","documentation":"Thrown by validateRequest's default branch when request.type is not one of 'result' | 'compare' | 'prompt-only' | 'prompt-iterate'. The message interpolates the offending type value. This is an EvaluationValidationError and typically indicates a typo, a version mismatch, or an unvalidated payload reaching the service.","triggerScenarios":"evaluate({type:'results'}), type:'comparison', type:undefined, or any string outside the four supported literals (e.g. after a new type was added upstream but the caller is on an older SDK, or vice versa).","commonSituations":"Typos in the type field; sending raw JSON from an API without validating the discriminant; version skew where a newer client sends a type an older service build doesn't know; discriminated-union not enforced in caller types.","solutions":["Correct request.type to one of the four supported literals","Type the request as the library's EvaluationRequest union so TypeScript rejects unknown types at compile time","Validate inbound payloads (e.g. zod enum) before forwarding to evaluate","Align client and service versions if the type is genuinely new"],"exampleFix":"// before\nawait svc.evaluate({ type: 'comparison', ... } as any);\n\n// after\nimport type { EvaluationRequest } from '...';\nconst req: EvaluationRequest = { type: 'compare', ... };\nawait svc.evaluate(req);","handlingStrategy":"type-guard","validationCode":"const TYPES = ['result','compare','prompt-only','prompt-iterate'] as const;\nif (!TYPES.includes(req.type)) throw new Error(`Unsupported type ${req.type}`);","typeGuard":"const isEvaluationType = (t: unknown): t is 'result'|'compare'|'prompt-only'|'prompt-iterate' =>\n  ['result','compare','prompt-only','prompt-iterate'].includes(t as string);","tryCatchPattern":null,"preventionTips":["Type requests as EvaluationRequest so TS catches bad discriminants","Validate external payloads (zod enum) before forwarding","Keep client and service versions aligned"],"tags":["evaluation","validation","discriminated-union","typescript"],"backgroundTag":"invalid-discriminator-value","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}