badges/shields · error · InvalidResponse
metrics missing for branch
Error message
metrics missing for branch
What it means
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.
Source
Thrown at services/scrutinizer/scrutinizer-base.js:33
transformBranchInfo({ json, wantedBranch }) {
const branch = wantedBranch || json.default_branch
const noBranchInfoMessage = wantedBranch
? 'branch not found'
: 'unavailable for default branch'
const branchInfo = json.applications[branch]
if (!branchInfo) {
throw new NotFound({ prettyMessage: noBranchInfoMessage })
}
return branchInfo
}
transformBranchInfoMetricValue({ json, branch, metric }) {
const branchInfo = this.transformBranchInfo({ json, wantedBranch: branch })
if (!branchInfo.index) {
throw new InvalidResponse({ prettyMessage: 'metrics missing for branch' })
}
const {
index: {
_embedded: {
project: { metric_values: metricValues },
},
},
} = branchInfo
return { value: metricValues[metric] }
}
}
View on GitHub (pinned to 766fd8bc89)
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
Defensive patterns
Strategy: try-catch
Type guard
function hasMetrics(branchInfo) {
return Boolean(branchInfo && branchInfo.index && branchInfo.index._embedded && branchInfo.index._embedded.project && branchInfo.index._embedded.project.metric_values)
} Try / catch
try {
const badge = await fetchBadgeUrl(scrutinizerCoverageUrl)
} catch (e) {
if (/metrics missing for branch/.test(e.message)) {
console.warn('Scrutinizer has no computed metrics for this branch yet')
} else throw e
} Prevention
- 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)
When it happens
Trigger: 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.
Common situations: First Scrutinizer build failing so metrics never populate; branch analysis pending; Scrutinizer API degraded or returning partial JSON; repo added but inspection config disabled.
Related errors
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/b1f8a478698fcb76.
Report an issue: GitHub.