{"record":{"id":"7efc3bae53e1603f","repo":"linshenkx/prompt-optimizer","slug":"evaluation-result-is-missing-score-for-fieldnam","errorCode":null,"errorMessage":"Evaluation result is missing score for \"${fieldName}\".","messagePattern":"Evaluation result is missing score for \"(.+?)\"\\.","errorType":"exception","errorClass":"EvaluationParseError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":3123,"sourceCode":"   * 标准化评估响应（统一结构）\n   */\n  private normalizeEvaluationResponse(\n    data: any,\n    type: EvaluationType,\n    metadata?: EvaluationResponse['metadata']\n  ): EvaluationResponse {\n    if (!data || typeof data !== 'object') {\n      throw new EvaluationParseError('Evaluation result is not a valid object.');\n    }\n\n    if (data.score === undefined || data.score === null) {\n      throw new EvaluationParseError('Evaluation result is missing the \"score\" field.');\n    }\n\n    // 提取分数（0-100，整数）\n    const extractScore = (value: any, fieldName: string): number => {\n      if (value === undefined || value === null) {\n        throw new EvaluationParseError(`Evaluation result is missing score for \"${fieldName}\".`);\n      }\n      const num = typeof value === 'number' ? value : parseInt(String(value));\n      if (isNaN(num)) {\n        throw new EvaluationParseError(`Invalid numeric score for \"${fieldName}\": ${value}`);\n      }\n      return Math.max(0, Math.min(100, num));\n    };\n\n    const tryExtractScore = (value: any, fieldName: string): number | null => {\n      try {\n        return extractScore(value, fieldName);\n      } catch {\n        return null;\n      }\n    };\n\n    const toDimension = (key: string, label: string, scoreValue: any): EvaluationDimension | null => {\n      const score = tryExtractScore(scoreValue, `dimension.${key}`);","sourceCodeStart":3105,"sourceCodeEnd":3141,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L3105-L3141","documentation":"EvaluationParseError thrown by the inner extractScore helper when a specific dimension/sub-score (fieldName) inside the evaluation result is undefined or null. It fires while extracting individual criterion scores, naming the offending field in the message. The top-level score check has already passed by this point.","triggerScenarios":"A multi-dimension evaluation result where one dimension (e.g. accuracy, relevance) is absent or null in the JSON, e.g. {\"score\": 80, \"dimensions\": {\"accuracy\": null }}.","commonSituations":"Judge model skipping dimensions it deems not applicable; prompt listing dimensions the model doesn't echo back; partial JSON truncation dropping trailing fields.","solutions":["Inspect the message for the missing fieldName and check the raw model output for that key","Require every dimension in the judge prompt explicitly ('you MUST provide a numeric score for each of: ...')","Increase max_tokens so trailing dimensions aren't truncated"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const dims = ['accuracy','relevance','clarity']; // assert before/at prompt time\nconst missing = dims.filter(d => parsed?.dimensions?.[d] == null);","typeGuard":"const hasAllDimensionScores = (v: any, dims: string[]): boolean => dims.every(d => v?.dimensions?.[d] != null);","tryCatchPattern":"try { ... } catch (e) { if (e instanceof EvaluationParseError && /missing score for/.test(e.message)) { /* re-prompt with mandatory dimensions, retry */ } else throw e; }","preventionTips":["Explicitly list every required dimension in the judge prompt with 'MUST provide numeric score'","Raise max_tokens to avoid truncated trailing dimensions"],"tags":["evaluation","parsing","score","dimensions"],"backgroundTag":"llm-output-parse-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}