Skip to content

fix(fetcher): Tolerate missing unit key in warn_multiple_units - #80

Merged
BojanOro merged 1 commit into
mainfrom
fix/warn-multiple-units-missing-unit
Oct 23, 2026
Merged

BojanOro merged 1 commit into
mainfrom
fix/warn-multiple-units-missing-unit

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Fixes PRODENG-2990.

Datadog sometimes returns a timeseries with no unit key at all, where it used to return "unit": null. parse_and_assert_unit already handles this when the query file configures a unit, but warn_multiple_units indexed series_list[0]["unit"] directly and raised KeyError: 'unit'. That crashed the usage-accountant cronjob in every region.

This switches it to .get("unit"), so a missing unit is handled the same way as null. It also adds a main() test with a configured unit and a series that has no unit key. Without the fix, the test fails with the same KeyError.

via Trent Schmidt.

--

View Junior Session [Sentry]

Datadog can omit the unit key from a series entirely instead of returning null. Treat a missing key the same as null so the cronjob no longer crashes with KeyError.

Refs PRODENG-2990

Co-Authored-By: Trent Schmidt <trent.schmidt@sentry.io>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 23, 2026 14:17
@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown

PRODENG-2990

@BojanOro
BojanOro merged commit f625115 into main Oct 23, 2026
17 checks passed
@BojanOro
BojanOro deleted the fix/warn-multiple-units-missing-unit branch October 23, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant