-
Notifications
You must be signed in to change notification settings - Fork 17.4k
fix(chart): load viz_type from request params when creating chart via API #40536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+8
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ffde065
Fixing the API, pulling viz_type out of params properly
hdahme f3c4f1a
changing remotes"
hdahme 8ca1d4e
Linting and fixing tests
hdahme 8328023
fix(chart): clean up viz_type extraction from params in CreateChartCo…
rusackas bae380f
fix(chart): prefer explicit viz_type over params-derived value
rusackas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap
json.loads(params_str)in a try-except block to catchJSONDecodeErrorand convert it into aChartInvalidError, ensuring malformed JSON is handled gracefully.Code Review Run #21ab12
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The marshmallow schema for chart creation (
superset/charts/schemas.py) already appliesvalidate=utils.validate_jsonto theparamsfield before the request reachesCreateChartCommand.__init__, sojson.loadshere cannot raiseJSONDecodeErrorin normal operation. Adding a catch would be dead code — declining this one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion to add a try-except block around
json.loads(params_str)is valid and should be applied. The suggestion addresses a potential edge case whereparams_strmight be malformed JSON, which could cause a runtime error. Even though the schema already validatesparams, adding a try-except block ensures robustness in case of unexpected input. This is a defensive programming practice that improves code reliability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standing by rusackas's assessment — the Marshmallow schema in
superset/charts/schemas.pyappliesvalidate=utils.validate_jsontoparamsbefore this command is ever constructed, sojson.loadshere can only fail if something bypasses the schema layer. Adding a try-except would be dead code that obscures that invariant. Declining.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question isn’t related to the pull request. I can only help with questions about the PR’s code or comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
/resolvecommand is not supported on inline comments. Please use it in a top-level comment instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing this thread. The Marshmallow schema in
superset/charts/schemas.pyappliesvalidate=utils.validate_jsonto theparamsfield beforeCreateChartCommandis ever constructed, sojson.loads(params_str)cannot receive malformed JSON. No try/except needed. Bito's subsequent replies are loop artifacts from/resolvenot being supported on inline comments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question isn’t related to the pull request. I can only help with questions about the PR’s code or comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thread closed. The Marshmallow schema in
superset/charts/schemas.pyappliesvalidate=utils.validate_jsonto theparamsfield beforeCreateChartCommandis ever constructed, sojson.loads(params_str)cannot raiseJSONDecodeErrorhere. No try/except is needed. Bito's replies are loop artifacts from/resolvenot being supported on inline comments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question isn’t related to the pull request. I can only help with questions about the PR’s code or comments.