eschutho opened a new pull request, #44585:
URL: https://github.com/apache/superset/pull/44585

   ### SUMMARY
   When a dashboard native filter fails to load its values, `FilterValue` hands 
the error to `ErrorMessageWithStackTrace`. That component only uses a 
registered renderer when the error's `error_type` matches the error message 
registry. For anything else it renders the `fallback`, and that fallback was a 
hardcoded **"Network error — Network error while attempting to fetch 
resource"**. The actual error message was dropped.
   
   So any failure without a registered `error_type` looked like a network 
problem. For example, a ClickHouse query failed with a resource limit error 
(`TOO_MANY_ROWS_OR_BYTES`), where the response was `{"errors": [{"message": 
"..."}]}` with no `error_type`, and the filter showed "Network error". That 
sends anyone debugging the dashboard after connectivity, permissions or timeout 
problems when the real cause is a database error.
   
   This change keeps `ErrorMessageWithStackTrace` and the compact `ErrorAlert`, 
and makes the fallback use the real message when there is one:
   
   - The message is taken from `errors[0].message`, then `error`, then 
`message`, which covers every shape `getClientErrorObject` produces. Those are 
a JSON `{errors: [...]}` response, a plain `Error`, and a `Failed to fetch` 
`TypeError`. The last one already resolves to `{ error: 'Network error' }`, so 
real network failures still say so.
   - If a message exists, the title is `Cannot load filter`, a string already 
translated and used by `FiltersConfigForm` for the same situation. The generic 
"Network error" title and text are only used when there is no message at all.
   - The compact `ErrorAlert` shows only the title inline. The message goes in 
the tooltip and in a modal opened by clicking, so long database errors don't 
break the filter bar layout.
   
   The change is limited to this one render site.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   **Before:** the filter shows `Network error`, and the tooltip/modal says 
`Network error while attempting to fetch resource`, whatever the actual failure 
was.
   
   **After:** the filter shows `Cannot load filter`, and the tooltip/modal 
shows the actual error, e.g. `Error: Received ClickHouse exception, code: 396 
... (TOO_MANY_ROWS_OR_BYTES)`. If the failure has no message at all, it still 
shows `Network error`.
   
   ### TESTING INSTRUCTIONS
   Unit tests:
   ```
   cd superset-frontend
   npx jest 
src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.test.tsx
   ```
   New cases cover:
   1. an `errors: [{ message }]` payload with no `error_type`, which shows the 
database message and not "Network error";
   2. a `{ error: '...' }` object with no `errors` array, which shows that 
message;
   3. no message at all, which still shows the "Network error" fallback.
   
   The existing error-state test was also updated, because its payload carries 
a message.
   
   Manual:
   1. Create a native select filter on a dataset whose values query fails in 
the database. For example, point it at a virtual dataset with invalid SQL, or 
at a column whose query hits a database resource limit.
   2. Open the dashboard. The filter should show "Cannot load filter", and 
hovering or clicking it should show the database error text instead of "Network 
error while attempting to fetch resource".
   3. Block the `/api/v1/chart/data` request in devtools. The filter should 
still report a network error.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to