aminghadersohi commented on code in PR #42390:
URL: https://github.com/apache/superset/pull/42390#discussion_r3717099609
##########
superset-frontend/src/SqlLab/components/TablePreview/index.tsx:
##########
@@ -257,14 +261,15 @@ const TablePreview: FC<Props> = ({ dbId, catalog, schema,
tableName }) => {
}
if (hasMetadataError || metadataExtrError) {
- return (
- <Alert
- type="warning"
- message={
- ((metadataError || metadataExtrError) as ClientErrorObject)?.error
- }
- />
- );
+ // Pass the structured SupersetError through to ErrorMessageWithStackTrace
so
+ // that OAuth2 redirect errors (error_type=OAUTH2_REDIRECT) render the
+ // "Authorization needed" link and auto-retry once the OAuth2 dance
completes.
+ // The source="crud" value drives the tag-invalidation retry in
+ // OAuth2RedirectMessage.tsx (which invalidates the TableMetadatas tag).
+ const errorPayload = (
+ (metadataError || metadataExtrError) as ClientErrorObject
+ )?.errors?.[0];
+ return <ErrorMessageWithStackTrace error={errorPayload} source="crud" />;
Review Comment:
Valid — fixed in 0fe4f25.
`(metadataError || metadataExtrError)` always preferred the main request, so
a generic failure there (raw 500, timeout, `Failed to fetch`) would fall
through to the plain-`Alert` branch and swallow an actionable `OAUTH2_REDIRECT`
payload arriving from the extended-metadata request. Now the selection picks
whichever response actually carries a structured `errors[]`:
```tsx
const clientErrors = [metadataError, metadataExtrError].filter(
Boolean,
) as ClientErrorObject[];
const errorPayload = clientErrors.find(({ errors }) => errors?.length)
?.errors?.[0];
return errorPayload ? (
<ErrorMessageWithStackTrace error={errorPayload} source="crud" />
) : (
<Alert type="warning" message={clientErrors[0]?.error} />
);
```
The plain-message fallback still applies when neither response has a
structured payload, so the regression fixed earlier in this PR stays fixed.
Covered by a new test — `surfaces an OAUTH2_REDIRECT from the extended
metadata request when the main request fails generically` (500 on
`table_metadata`, 403 + `OAUTH2_REDIRECT` on `table_metadata/extra`, asserts
the authorization link renders). Verified non-vacuous: it fails with the old
`clientErrors[0]?.errors?.[0]` selection and passes with the fix. Full suite:
9/9 green.
--
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]