aminghadersohi opened a new pull request, #42390:
URL: https://github.com/apache/superset/pull/42390
### SUMMARY
Superset's per-user database OAuth2 flow signals uniformly via
`OAuth2RedirectError` (403, `error_type=OAUTH2_REDIRECT`). SQL Lab's
DB/schema/table selectors already handle this: they render the error via
`ErrorMessageWithStackTrace source="crud"`, and `OAuth2RedirectMessage` listens
for the popup completion and retries by invalidating the relevant RTK Query
tags.
The SQL Lab **table column/metadata preview** (shown when expanding a table
in the left panel) did not. On error it rendered a plain `<Alert
type="warning">` built from a flattened error string, so an OAuth2-required
response never showed the authorization link and never refetched after the user
completed the OAuth2 dance elsewhere — it just sat as a dead warning banner.
This PR makes the preview consistent with the rest of SQL Lab:
1. **`TablePreview/index.tsx`** — render metadata errors via
`ErrorMessageWithStackTrace error={...} source="crud"`, passing the structured
`SupersetError` (`error.errors[0]`) that RTK Query already provides instead of
flattening it to a string. This lets the registered `OAuth2RedirectMessage`
component render the "provide authorization" link and listen for completion,
exactly like `DatabaseSelector`/`TableExploreTree`.
2. **`OAuth2RedirectMessage.tsx`** — the `crud`-source retry only
invalidated `Schemas`, `Catalogs`, and `Tables`, but the table metadata queries
(`useTableMetadataQuery` / `useTableExtendedMetadataQuery`) provide the
**`TableMetadatas`** tag. Without invalidating it, the preview would never
refetch after re-auth. Add `TableMetadatas` to the invalidated tags so the
preview auto-refreshes once the OAuth2 dance completes.
### BEFORE/AFTER
| | Before | After |
|---|---|---|
| Table preview metadata error | ❌ plain warning Alert, no auth link, no
retry | ✅ "Authorization needed" link, auto-refetches after OAuth2 |
### TESTING INSTRUCTIONS
1. Create a DB connection that uses per-user OAuth2 (e.g. Snowflake external
OAuth).
2. In SQL Lab, expand a table in the left panel to open the column/metadata
preview — you should see the "Authorization needed" banner with a link.
3. Click the link and complete the OAuth2 dance in the popup.
4. **Expected:** the preview populates automatically (columns/metadata)
without a manual refresh.
Unit tests added:
- `TablePreview.test.tsx` — a metadata error with
`error_type=OAUTH2_REDIRECT` renders the OAuth2 authorization link.
- `OAuth2RedirectMessage.test.tsx` — the `crud` retry now also invalidates
`TableMetadatas`.
### ADDITIONAL INFORMATION
- [x] Changes UI
--
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]