fix: Return 400 for missing metrics in chart data preview#1376
Draft
sentry[bot] wants to merge 1 commit into
Draft
fix: Return 400 for missing metrics in chart data preview#1376sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Author
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1376 +/- ##
==========================================
- Coverage 58.66% 58.64% -0.03%
==========================================
Files 132 132
Lines 15690 15697 +7
==========================================
Hits 9205 9205
- Misses 6485 6492 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 issue where
ValueError: At least one metric is required for aggregated chartswas being reported as a 500 error to Sentry (DALGO-BACKEND-1W4).Problem:
The
/api/charts/chart-data-preview/and/api/charts/chart-data-preview/total-rows/endpoints were catchingValueError(raised when a non-table chart type was requested without metrics) with a broadexcept Exceptionblock. This resulted in an HTTP 500 response and an unnecessary error log in Sentry, treating a client-side input validation issue as a server error.Solution:
get_chart_data_previewto specifically catchValueErrorbefore the generalExceptionhandler.get_chart_data_preview_total_rowsto also specifically catchValueError.ValueErrorinstances, an HTTP 400 (Bad Request) is now returned to the client, providing a more accurate response for invalid input.ValueErrorcases has been downgraded fromerrortowarningto prevent them from being reported as critical issues in Sentry.This change aligns the behavior of the chart data preview endpoints with the existing
get_chart_dataendpoint, which already handlesValueErrorin a similar manner.Fixes DALGO-BACKEND-1W4