Repository navigation
Conversation
…n get_dashboard_urls BaseReportState.get_dashboard_urls parses extra.dashboard.anchor with json.loads under a bare `except json.JSONDecodeError`. Because extra is an untyped marshmallow Dict field, anchor may be any JSON value; a non-string (int/list/dict/bool) makes json.loads raise a raw TypeError, which is not a JSONDecodeError subclass and therefore propagates uncaught, crashing the report/alert Celery job's screenshot/permalink step. Widen the guard to `except (TypeError, json.JSONDecodeError)`, mirroring the sibling query_context parsing already in this file. Non-string anchors now fall through to the existing graceful single-tab fallback. Pure additive except-widening; no behavior change for string or JSON-list anchors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review Agent Run #72fe52Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44450 +/- ##
==========================================
- Coverage 80.65% 80.65% -0.01%
==========================================
Files 2942 2942
Lines 175692 175692
Branches 40788 40788
==========================================
- Hits 141705 141703 -2
- Misses 31325 31327 +2
Partials 2662 2662
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| ) | ||
| return urls | ||
| except json.JSONDecodeError: | ||
| except (TypeError, json.JSONDecodeError): |
There was a problem hiding this comment.
Suggestion: The widened handler also catches TypeError from _get_tabs_urls, so permalink-generation failures are misclassified as invalid anchors and trigger the single-tab fallback.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Error handling
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/commands/report/execute.py
**Line:** 621:621
**Comment:**
*Error Handling: The widened handler also catches `TypeError` from `_get_tabs_urls`, so permalink-generation failures are misclassified as invalid anchors and trigger the single-tab fallback.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
The flagged issue is correct. Widening the exception handler to catch Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well? superset/commands/report/execute.py |
SUMMARY
BaseReportState.get_dashboard_urls(insuperset/commands/report/execute.py) parsesextra.dashboard.anchorwithjson.loadsunder a bareexcept json.JSONDecodeError. Becauseextrais an untyped marshmallowDictfield (superset/reports/schemas.py),anchorcan be any JSON value — not just a string.Problem: When
anchoris a non-string JSON value (int, list, dict, bool),json.loads(anchor)raises a rawTypeError, which is not a subclass ofjson.JSONDecodeError(JSONDecodeErroris aValueError;TypeErroris unrelated). The existingexcept json.JSONDecodeErrordoes not catch it, so theTypeErrorpropagates uncaught.get_dashboard_urls()runs on the live report/alert execution path — a background Celery job — reached both fromBaseReportState._get_screenshots(dashboard screenshot path) and directly fromAsyncExecuteReportScheduleCommand.run(permalink pre-commit step). So any report whose storedextra.dashboard.anchoris a non-string value crashes that job's screenshot/permalink step.Fix: Widen the guard to
except (TypeError, json.JSONDecodeError), mirroring the siblingquery_contextparsing already in this same file (AsyncExecuteReportScheduleCommand,except (TypeError, json.JSONDecodeError) as ex:). This is a pure additive except-tuple widening — no new exception class, no behavior change for any input that already worked (string anchors, valid/invalid JSON-list anchors). Only the previously-crashing non-string-anchor case now falls through to the existing graceful "fall back to single tab" path, exactly like the sibling site's established behavior.This is sibling-site drift: the same file has the correct broader guard one method over. The same bug class at validation time was addressed in #44404 (
base.py::_validate_report_extra), whose body explicitly flagged thisexecute.pyanchor-handling site as a known follow-up gap, out of scope for that PR. This PR closes that follow-up. See also #42401 for the original sibling-site-drift precedent pattern.TESTING INSTRUCTIONS
Added a regression case to the existing parametrized
test_get_dashboard_urls_with_multiple_tabsintests/unit_tests/commands/report/execute_test.pywith a non-string anchor (42), asserting it does not raiseTypeErrorand instead falls back gracefully to a single-tab permalink.TypeError: Input string must be text, not bytes(rawTypeErrorpropagates).ADDITIONAL INFORMATION
🤖 Generated with Claude Code