Skip to content

Commit

Permalink
Handle location decoding errors
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Mar 24, 2023
1 parent d6591ab commit 04b74c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions runtime/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ func (r *CoverageReport) UnmarshalJSON(data []byte) error {
}

for locationID, locationCoverage := range cr.Coverage { // nolint:maprange
location, _, _ := common.DecodeTypeID(nil, locationID)
location, _, err := common.DecodeTypeID(nil, locationID)
if err != nil {
return err
}
if location == nil {
return fmt.Errorf("invalid Location ID: %s", locationID)
}
Expand All @@ -442,7 +445,10 @@ func (r *CoverageReport) UnmarshalJSON(data []byte) error {
r.Locations[location] = struct{}{}
}
for _, locationID := range cr.ExcludedLocations {
location, _, _ := common.DecodeTypeID(nil, locationID)
location, _, err := common.DecodeTypeID(nil, locationID)
if err != nil {
return err
}
if location == nil {
return fmt.Errorf("invalid Location ID: %s", locationID)
}
Expand Down

0 comments on commit 04b74c4

Please sign in to comment.