badges / shields

Concise, consistent, and legible badges in SVG and raster format
https://shields.io
Creative Commons Zero v1.0 Universal
23.75k stars 5.5k forks source link

[ScrutinizerQuality] TypeError: Cannot destructure property `index` of 'undefined' or 'null'. #3808

Closed sentry-io[bot] closed 5 years ago

sentry-io[bot] commented 5 years ago

Sentry Issue: SHIELDS-36

TypeError: Cannot destructure property `index` of 'undefined' or 'null'.
  File "/home/m/shields/services/scrutinizer/scrutinizer-base.js", line 38, in ScrutinizerQuality.transformBranchInfoMetricValue
    } = this.transformBranchInfo({ json, wantedBranch: branch })
  File "/home/m/shields/services/scrutinizer/scrutinizer-quality.service.js", line 52, in ScrutinizerQuality.makeBadge
    const { value: score } = this.transformBranchInfoMetricValue({
  ?, in null.<anonymous>
calebcartwright commented 5 years ago

I did not realize the breadth of runtime errors we were having!

paulmelnikow commented 5 years ago

Yea, I was similarly a little surprised. Though, of course people have reported them from time to time. It's nice that we can address them proactively!

PyvesB commented 5 years ago

I believe that I've managed to figure out the edge-case for which this bug can happen. If the user does not specify a branch, the Scrutinizer service will use the default_branch instead (see here: https://github.com/badges/shields/blob/b3be4d94d5ef570b8daccfd088c343a958988843/services/scrutinizer/scrutinizer-base.js#L20). However, if the default branch does not have any analysis data available, we will try to destructure undefined. This will probably happen temporarily when the user sets the default branch to one for which the CI has not yet run.

I'll submit a fix.