{"record":{"id":"b1f8a478698fcb76","repo":"badges/shields","slug":"metrics-missing-for-branch","errorCode":null,"errorMessage":"metrics missing for branch","messagePattern":"metrics missing for branch","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/scrutinizer/scrutinizer-base.js","lineNumber":33,"sourceCode":"\n  transformBranchInfo({ json, wantedBranch }) {\n    const branch = wantedBranch || json.default_branch\n    const noBranchInfoMessage = wantedBranch\n      ? 'branch not found'\n      : 'unavailable for default branch'\n\n    const branchInfo = json.applications[branch]\n    if (!branchInfo) {\n      throw new NotFound({ prettyMessage: noBranchInfoMessage })\n    }\n\n    return branchInfo\n  }\n\n  transformBranchInfoMetricValue({ json, branch, metric }) {\n    const branchInfo = this.transformBranchInfo({ json, wantedBranch: branch })\n    if (!branchInfo.index) {\n      throw new InvalidResponse({ prettyMessage: 'metrics missing for branch' })\n    }\n    const {\n      index: {\n        _embedded: {\n          project: { metric_values: metricValues },\n        },\n      },\n    } = branchInfo\n\n    return { value: metricValues[metric] }\n  }\n}\n","sourceCodeStart":15,"sourceCodeEnd":46,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/scrutinizer/scrutinizer-base.js#L15-L46","documentation":"InvalidResponse thrown when the Scrutinizer branch info exists but has no `index` object, meaning the branch was registered in Scrutinizer but its metrics (coverage/score) were never computed or the API returned an incomplete payload. The service guards against dereferencing index._embedded.project.metric_values on undefined.","triggerScenarios":"Requesting a Scrutinizer coverage or quality score badge for a branch whose analysis produced no index data — e.g. build queued/failed, analysis still running, or Scrutinizer returned an applications entry without an index for that branch.","commonSituations":"First Scrutinizer build failing so metrics never populate; branch analysis pending; Scrutinizer API degraded or returning partial JSON; repo added but inspection config disabled.","solutions":["Check the project on scrutinizer-ci.com for a completed, successful analysis of that branch","Re-run the Scrutinizer build and retry the badge once metrics exist","Confirm .scrutinizer.yml is configured so the inspection produces metric values","Retry later if the Scrutinizer API was returning incomplete data"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasMetrics(branchInfo) {\n  return Boolean(branchInfo && branchInfo.index && branchInfo.index._embedded && branchInfo.index._embedded.project && branchInfo.index._embedded.project.metric_values)\n}","tryCatchPattern":"try {\n  const badge = await fetchBadgeUrl(scrutinizerCoverageUrl)\n} catch (e) {\n  if (/metrics missing for branch/.test(e.message)) {\n    console.warn('Scrutinizer has no computed metrics for this branch yet')\n  } else throw e\n}","preventionTips":["Only embed coverage/quality badges for branches with a completed successful Scrutinizer analysis","Retry badge rendering after the Scrutinizer build finishes (metrics appear asynchronously)","Monitor the Scrutinizer project page to confirm metrics are displayed before embedding badges","Handle badge failures gracefully (show 'unknown' badge instead of breaking the README build)"],"tags":["scrutinizer","invalid-response","metrics","badge"],"backgroundTag":"upstream-api-invalid-response","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}