Skip to content

Conversation

@nikkikapadia
Copy link
Member

Slack thread for context: https://sentry.slack.com/archives/C07H2DHMSS0/p1764091469147239

Extrapolation mode would not be accepted as a string in the validator (which is what it gets passed to the backend as) so it was throwing an error on detector updates. Along with this I had to fix some tests and other logic that went into validating the extrapolation mode so we ensure we're comparing correct types.

@nikkikapadia nikkikapadia marked this pull request as ready for review November 25, 2025 21:38
@nikkikapadia nikkikapadia requested a review from a team as a code owner November 25, 2025 21:38
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 25, 2025
if name == extrapolation_mode:
extrapolation_mode = ExtrapolationMode(value)
break
if type(extrapolation_mode) is not ExtrapolationMode:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a validate_extrapolation_mode() function to this validator that will transform the value into the enum class automatically? That way you won't need to do it here

if extrapolation_mode is not None:
extrapolation_mode = ExtrapolationMode(extrapolation_mode)
extrapolation_mode_options = ExtrapolationMode.as_text_choices()
for name, value in extrapolation_mode_options:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, you can add a classmethod from_str(self, name: str) function to ExtrapolationMode. We do that for some other enums. Then you can just do ExtrapolationMode.from_str(extrapolation_mode)


def _validate_extrapolation_mode(self, extrapolation_mode: str) -> None:
if extrapolation_mode == ExtrapolationMode.SERVER_WEIGHTED.value:
if extrapolation_mode is not None and extrapolation_mode not in [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also be simpler if you return the enum from the validator

"Failed to send data to Seer, cannot update detector"
)

numerical_extrapolation_mode = format_extrapolation_mode(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you return an enum, you can instead do:

numerical_extrapolation_mode = data_source.get("extrapolation_mode", snuba_query.extrapolation_mode.value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants