fix: streaming export losing g context
SUMMARY
Streaming CSV exports create a new Flask app context when the generator runs, which causes flask.g attributes from the original request to be lost. This can break functionality that relies on request-scoped data stored in g.
This fix:
- Captures all
flask.gattributes when the command is initialized (during the original request context) - Restores them via
preserve_g_context()when the generator executes in the new app context
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - backend change
TESTING INSTRUCTIONS
- Run existing tests:
pytest tests/unit_tests/commands/sql_lab/streaming_export_command_test.py -v - All 16 tests should pass
ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in SIP-59)
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
CodeAnt AI is reviewing your PR.
Thanks for using CodeAnt! π
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
Share on X Β· Reddit Β· LinkedIn
Nitpicks π
| πΒ No security issues identified |
β‘Β Recommended areas for review
|
Deploy Preview for superset-docs-preview ready!
| Name | Link |
|---|---|
| Latest commit | 37119f90451106b365eaeba3f7ca6ad7a194367a |
| Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/695e49b1b3c15a0008180d16 |
| Deploy Preview | https://deploy-preview-36950--superset-docs-preview.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
CodeAnt AI finished reviewing your PR.
Codecov Report
:x: Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 68.17%. Comparing base (2080633) to head (cf3d135).
:warning: Report is 24 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| superset/commands/streaming_export/base.py | 23.52% | 13 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #36950 +/- ##
===========================================
+ Coverage 0 68.17% +68.17%
===========================================
Files 0 639 +639
Lines 0 47665 +47665
Branches 0 5205 +5205
===========================================
+ Hits 0 32494 +32494
- Misses 0 13891 +13891
- Partials 0 1280 +1280
| Flag | Coverage Ξ | |
|---|---|---|
| hive | 43.09% <23.52%> (?) |
|
| mysql | 66.17% <23.52%> (?) |
|
| postgres | 66.22% <23.52%> (?) |
|
| presto | 46.69% <23.52%> (?) |
|
| python | 68.14% <23.52%> (?) |
|
| sqlite | 65.94% <23.52%> (?) |
|
| unit | 100.00% <ΓΈ> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Code Review Agent Run #8fd3f4
Actionable Suggestions - 0
Review Details
-
Files reviewed - 1 Β· Commit Range:
37119f9..cf3d135- superset/commands/streaming_export/base.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - βοΈ Successful
- Detect-secrets (Secret Scanner) - βοΈ Successful
- MyPy (Static Code Analysis) - βοΈ Successful
- Astral Ruff (Static Code Analysis) - βοΈ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help