fix(explore): show validation errors in View Query modal#35969
Conversation
Code Review Agent Run #a4a403Actionable Suggestions - 0Additional Suggestions - 5
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 |
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Negative logic in result type check may bypass error handling ▹ view | ||
| Potential undefined language prop ▹ view | ||
| Missing validation for query field on successful status ▹ view |
Files scanned
| File Path | Reviewed |
|---|---|
| superset/commands/chart/data/get_data_command.py | ✅ |
| superset-frontend/src/explore/components/controls/ViewQueryModal.tsx | ✅ |
| superset/charts/schemas.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
|
🎪 Showtime deployed environment on GHA for bf4a66e • Environment: http://35.92.249.128:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for 565fcfb • Environment: http://18.236.166.70:8080 (admin/admin) |
565fcfb to
2f41fce
Compare
|
🎪 Showtime deployed environment on GHA for 2f41fce • Environment: http://52.40.60.56:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for 3f34a81 • Environment: http://44.244.205.125:8080 (admin/admin) |
When chart queries fail due to validation errors (e.g., missing required fields, invalid metrics), the View Query modal now displays helpful error messages instead of showing a blank panel. This restores functionality that was broken in 2023 when ChartDataCommand was added. The command raised exceptions for ALL errors, but should only fail-fast for data execution requests, not query-only requests. Changes: - Backend: Skip error check in ChartDataCommand for result_type='query' - Schema: Make query field optional (validation errors return error without SQL) - Frontend: Display Alert component for errors, use item.language from backend - Tests: Add 7 unit tests including regression test to prevent future breakage Fixes #35492 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add React Testing Library test to verify that ViewQueryModal correctly displays validation errors in an Alert component when the backend returns errors in the query result. This test ensures the fix for issue #35492 continues to work correctly by verifying the frontend properly renders error messages instead of showing a blank panel. Test coverage: - Mocks chart/data API to return validation error - Verifies Alert component is rendered - Verifies error message is displayed Related to #35492 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…odal When SQL generation succeeds but optimization/parsing fails, View Query modal now displays both the error message and the SQL that failed to parse. This is Phase 2 of the fix for #35492. Phase 1 fixed validation errors (before SQL generation). Phase 2 fixes parsing errors (after SQL generation, during optimization). Backend changes: - Added SupersetParseError handling in _get_query() - Extracts SQL from error.extra['sql'] when parsing fails - Returns both query and error to frontend Frontend changes: - Updated ViewQueryModal to render both Alert and ViewQuery simultaneously - Changed from ternary (either/or) to conditional rendering (both) - Added Fragment wrapper to support multiple children Tests: - Added backend unit test for SupersetParseError handling - Added frontend test for rendering both error and SQL - All 8 backend tests passing - All 2 frontend tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ery modal Addresses PR feedback for safer SQL extraction from parsing errors: - Use explicit None check instead of truthiness to preserve falsy SQL like "" - Split edge case tests into separate functions for better granularity - Remove time-specific references from test docstrings Changes: - query_actions.py: Check `is not None` to avoid discarding valid empty SQL - test_get_data_command.py: Split combined test into two independent tests - test_get_query_handles_parsing_error_with_missing_sql_key - test_get_query_handles_parsing_error_with_null_sql_value 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Addresses PR feedback: - Remove redundant keys from Alert and ViewQuery components (Fragment already has key) - Improve Fragment key to use content-based identifiers (query/error content) instead of array index This follows React best practices by: 1. Avoiding duplicate keys on conditionally rendered children 2. Using stable, content-based keys instead of index-based keys 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| // Use content-based key when available, fall back to index | ||
| const key = item.query || item.error || `result-${index}`; | ||
| return ( | ||
| <Fragment key={key}> |
There was a problem hiding this comment.
Using query or error text as a React key could cause issues if the same error/query appears multiple times, or if very long SQL queries are used as keys. Consider using a more stable identifier or always use the index-based key pattern.
| // Use content-based key when available, fall back to index | |
| const key = item.query || item.error || `result-${index}`; | |
| return ( | |
| <Fragment key={key}> | |
| // Use index as key to avoid issues with duplicate or long query/error strings | |
| return ( | |
| <Fragment key={index}> |
|
🎪 Showtime deployed environment on GHA for 7620bc8 • Environment: http://52.24.34.130:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for 5030db3 • Environment: http://35.95.73.104:8080 (admin/admin) |
…ebase patterns Changed from content-based keys (item.query || item.error) to index-based keys for the Fragment elements in ViewQueryModal. This aligns with established Superset patterns (e.g., MarshmallowErrorMessage.tsx) for displaying static API response data. Both approaches are technically correct for static data, but index-based is simpler and more consistent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
🎪 Showtime deployed environment on GHA for add009b • Environment: http://35.166.36.14:8080 (admin/admin) |
SUMMARY
Fixes #35492 - Restores the ability to view helpful information in the "View Query" modal when chart queries fail.
This PR addresses a regression introduced during the 2023 command reorganization (commit 07bcfa9) that broke error handling for the View Query feature. Previously in Superset 4.1.3, when charts failed, users could view either SQL or error messages. The reorganization caused all errors to return 400 status codes, making the frontend unable to display any helpful information.
Two types of errors are now properly handled:
- Before: Blank modal or generic "Sorry, An error occurred" message
- After: Clear error message displayed in Alert component
- Before: 500 error, SQL lost completely
- After: Both error message AND SQL displayed together
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After

TESTING INSTRUCTIONS
Automated Tests
Manual Testing
Test Case 1: Validation Error (The Fix)
Test Case 2: Valid Chart (No Regression)
Test Case 3: Database Error (No Regression)
ADDITIONAL INFORMATION