fix: Validate chart metric column for non-count aggregations#1391
Draft
sentry[bot] wants to merge 1 commit into
Draft
fix: Validate chart metric column for non-count aggregations#1391sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the
ValueError: Column is required for avg aggregationissue (DALGO-BACKEND-2GW) by implementing early input validation for chart metrics.Previously, the API allowed requests with non-
countaggregations (e.g.,avg) to be submitted with an empty string for thecolumnfield. This would pass initial Pydantic validation but lead to aValueErrorat runtime inddpui/core/charts/charts_service.py. This runtime error was then caught and logged as anerrorin Sentry, generating unnecessary alerts for what is fundamentally a client-side input validation problem.Changes include:
@model_validator(mode='after')to theChartMetricschema inddpui/schemas/chart_schema.py. This validator now:columnvalues toNone.ValueErrorif a non-countaggregation is specified without a validcolumn(i.e.,columnisNone).logger.errortologger.warningin theValueErrorcatch blocks withinddpui/api/charts_api.pyfor chart data generation endpoints. This ensures that validation-related errors are logged appropriately without triggering high-severity Sentry alerts.This ensures that invalid chart metric configurations are rejected with a clear 422 HTTP response at the API boundary, improving API robustness and reducing Sentry noise. Existing runtime checks in
charts_service.pyremain as a defense-in-depth.Fixes DALGO-BACKEND-2GW