fix: Table preview - dimension fallback and API validation#1394
Draft
sentry[bot] wants to merge 1 commit into
Draft
fix: Table preview - dimension fallback and API validation#1394sentry[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 issue DALGO-BACKEND-1VW where table chart previews failed with "No dimensions found after normalization!" when
dimensions,dimension_col, andextra_dimensionwere allNonein the payload.Root Cause:
normalize_dimensionsfunction for table charts only checkedpayload.dimensionsand did not implement the intended fallback todimension_colorextra_dimensionwhenpayload.dimensionswas empty orNone./api/charts/chart-data-preview/endpoint lacked early input validation to reject payloads for table charts that had no dimension fields specified, leading to aValueErrorfurther down the call stack.Changes Made:
ddpui/core/charts/charts_service.py(normalize_dimensions): Implemented the fallback logic for table charts. Ifpayload.dimensionsis empty orNone, it now checkspayload.dimension_colandpayload.extra_dimensionto populate the dimensions list, aligning with the function's docstring and behavior for other chart types.ddpui/api/charts_api.py(get_chart_data_preview): Added early validation. For table chart previews, if no dimension fields (dimensions,dimension_col,extra_dimension) are provided in the payload, anHttpError(400)is now raised with a clear message, preventing the request from proceeding with invalid input.ddpui/core/charts/charts_service.py(get_chart_data_table_preview): Downgraded thelogger.errortologger.warningfor theValueErrorraised when no dimensions are found. This is because the API layer now handles this validation upfront with a 400 response, making theValueErroran expected outcome for invalid input rather than an unhandled error.Fixes DALGO-BACKEND-1VW