You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2026/07/24 15:39:08 UTC

[PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5145721233

   Good catch — you're right, and thanks for the precise diagnosis. Fixed in 3547e7f.
   
   The regression was exactly as described: `queryApi.ts:67` sets `errors: errorObj?.errors || []`, so any error without a structured SIP-40 `errors[]` array (raw 500, HTML error page, timeout, `Failed to fetch`) yielded an `undefined` payload, and `ErrorMessageWithStackTrace` fell through to a bare `ErrorAlert` titled "Unexpected error" with an empty body.
   
   Applied your suggested guard:
   
   ```tsx
   const clientError = (metadataError || metadataExtrError) as ClientErrorObject;
   const errorPayload = clientError?.errors?.[0];
   return errorPayload ? (
     <ErrorMessageWithStackTrace error={errorPayload} source="crud" />
   ) : (
     <Alert type="warning" message={clientError?.error} />
   );
   ```
   
   This keeps `TablePreview` consistent with the other `source="crud"` consumers you pointed at (`TableExploreTree`, `DatabaseSelector`, `TableSelector`), preserves the OAuth2 authorization link + retry on the structured path, and restores the original message text on every other path.
   
   Also added a regression test — `renders the error message when metadata fails without a structured error` — that mocks a 500 with `{ message: ... }` and no `errors[]`, asserting the message still surfaces.
   
   One note on verification: I couldn't get a clean local Jest run in this worktree (the repo requires Node ^24.16.0, this box has v22, and `fetch-mock` fails to intercept — the pre-existing tests fail identically on an unmodified checkout, so it's environmental, not the change). I validated the fix by tracing `parseErrorJson` (a `{message}` body with no `errors[]`/`stack` sets `error.error = message`, leaving `errors: []`), plus `tsc --noEmit`, prettier and oxlint clean on the touched files. Relying on CI for the actual test signal.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5071768958

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42390?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 65.06%. Comparing base ([`18f1dd3`](https://app.codecov.io/gh/apache/superset/commit/18f1dd394bbeaa11e2eb250a7fb09e367044c22b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`bc931df`](https://app.codecov.io/gh/apache/superset/commit/bc931df3b8627d0e432a51ae7dd6b4b138c8d3ab?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 304 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #42390      +/-   ##
   ==========================================
   + Coverage   65.03%   65.06%   +0.02%     
   ==========================================
     Files        2744     2744              
     Lines      153627   153628       +1     
     Branches    35226    35226              
   ==========================================
   + Hits        99915    99953      +38     
   + Misses      51805    51768      -37     
     Partials     1907     1907              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/42390/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/42390/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.44% <100.00%> (+0.04%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42390?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42390:
URL: https://github.com/apache/superset/pull/42390#discussion_r3676675358


##########
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:
   **Suggestion:** When both metadata requests fail, this always selects `metadataError` first. If the main metadata request has a generic error while the extended metadata request contains the actionable `OAUTH2_REDIRECT` payload, the OAuth-specific component and authorization link are suppressed. Select the structured OAuth error when either request provides one, or otherwise preserve the most useful error. [incorrect condition logic]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ OAuth authorization link can be suppressed.
   - ❌ Table preview does not retry after reauthentication.
   - ⚠️ Metadata requests can fail with inconsistent error types.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8bd29901218b44c5b072635144aac077&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8bd29901218b44c5b072635144aac077&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/SqlLab/components/TablePreview/index.tsx
   **Line:** 269:272
   **Comment:**
   	*Incorrect Condition Logic: When both metadata requests fail, this always selects `metadataError` first. If the main metadata request has a generic error while the extended metadata request contains the actionable `OAUTH2_REDIRECT` payload, the OAuth-specific component and authorization link are suppressed. Select the structured OAuth error when either request provides one, or otherwise preserve the most useful error.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42390&comment_hash=25a9c6214fc2187e28dd432175e6728d8680e59db0b95fbbbc02a20af0e37eb4&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42390&comment_hash=25a9c6214fc2187e28dd432175e6728d8680e59db0b95fbbbc02a20af0e37eb4&reaction=dislike'>👎</a>



##########
superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx:
##########
@@ -121,6 +121,7 @@ export function OAuth2RedirectMessage({
             { type: 'Schemas', id: 'LIST' },
             { type: 'Catalogs', id: 'LIST' },
             'Tables',
+            'TableMetadatas',

Review Comment:
   **Suggestion:** Invalidating the unscoped string tag refetches every active table-metadata query in the application, including previews for unrelated databases and tables. A single OAuth completion can therefore trigger a potentially large burst of metadata requests and UI updates. Use a table/database-scoped tag or pass the initiating resource identity through the CRUD error flow so only the failed preview is retried. [performance]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Unrelated SQL Lab metadata queries refetch.
   - ⚠️ Multiple database connections may receive unnecessary requests.
   - ⚠️ OAuth completion can cause avoidable UI updates.
   ```
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ac5f00c3450549dfa43f2d564c0d3a2e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ac5f00c3450549dfa43f2d564c0d3a2e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
   **Line:** 124:124
   **Comment:**
   	*Performance: Invalidating the unscoped string tag refetches every active table-metadata query in the application, including previews for unrelated databases and tables. A single OAuth completion can therefore trigger a potentially large burst of metadata requests and UI updates. Use a table/database-scoped tag or pass the initiating resource identity through the CRUD error flow so only the failed preview is retried.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42390&comment_hash=b48b1799cd63621a34f842c99f4e244a57f0879c22b1124ad23a1e2e8177633c&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42390&comment_hash=b48b1799cd63621a34f842c99f4e244a57f0879c22b1124ad23a1e2e8177633c&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5071633692

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #42390:
URL: https://github.com/apache/superset/pull/42390#discussion_r3717100423


##########
superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx:
##########
@@ -121,6 +121,7 @@ export function OAuth2RedirectMessage({
             { type: 'Schemas', id: 'LIST' },
             { type: 'Catalogs', id: 'LIST' },
             'Tables',
+            'TableMetadatas',

Review Comment:
   Considered and intentionally keeping the unscoped tag. Three reasons:
   
   **1. No resource identity is available here.** `OAuth2RedirectMessage` is generic across all four `source` values, and the only thing it receives is the `SupersetError`. The `OAUTH2_REDIRECT` payload carries `{url, tab_id, redirect_uri}` and nothing else (`superset/exceptions.py:360-368`) — no database, catalog, schema, or table. Passing resource identity "through the CRUD error flow" would mean adding it to the backend error `extra` and threading it through `ErrorMessageWithStackTrace` into every `source="crud"` consumer. That's a much larger change than this fix, and it isn't free of risk.
   
   **2. Unscoped is the established convention on this branch, not a new pattern.** The `crud` arm already invalidates `{Schemas, LIST}`, `{Catalogs, LIST}`, and the bare `'Tables'` tag — all equally unscoped, added in #41913. Scoping only `TableMetadatas` would make this line the odd one out without addressing the same breadth in its three siblings.
   
   **3. The blast radius is bounded, and the refetch is mostly desirable.** `invalidateTags` only refetches queries with *active subscribers*; unsubscribed cache entries are just marked invalid and refetched on next mount. The only subscriber of `useTableMetadataQuery` is `TablePreview`, which mounts once per pinned table tab in the South Pane (`SouthPane/index.tsx:191-213`) — a handful at most, not an application-wide burst. And OAuth2 credentials are per-database, so after re-authentication the sibling previews against that same database were failing for exactly the same reason and *should* refetch. The genuine over-invalidation is limited to pinned tables on other databases, which is bounded by the same small tab count.
   
   Happy to revisit as a separate change if the error payload ever grows database identity — that's the prerequisite for doing this properly rather than approximating it.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5071650885

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | bc931df3b8627d0e432a51ae7dd6b4b138c8d3ab |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a63871ca221c60008a772ea |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-42390--superset-docs-preview.netlify.app](https://deploy-preview-42390--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQyMzkwLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.T4_ViEsjH0Z0gL05MWX-WYi8z3QKzaiFhaHUoRYSpBc)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctBDsIgEAXQu8xaIsUEGm_gMT4wKSS04BRrGuPdy-5t3o-a1LV1ehLdyAu2kIax5m1JiCx7Tfm-v0uBVxWfnozq8IVVEz4yf5Vwl3PcyK3U8xXHtrCP2U0BxkzBaq1nOGcY9L8A) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-42390--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5186117863

   Thanks @rebenitez1802 — pushed 0fe4f25, which addresses your deferred nit and one remaining bot finding.
   
   **1. The headline behavior now has a real end-to-end test.** You were right that it was only asserted indirectly. New test `repopulates the preview once the OAuth2 dance completes`: renders with `table_metadata` returning 403 + `OAUTH2_REDIRECT`, waits for the authorization link, then flips the mock to a successful response and fires the completion `storage` event that `OAuth2RedirectMessage` listens for — asserting the preview actually repopulates with the column rows. Verified non-vacuous: removing `'TableMetadatas'` from the `invalidateTags` list makes it fail.
   
   **2. Fixed a real error-selection bug** flagged by the bot on `TablePreview/index.tsx`. `(metadataError || metadataExtrError)` always preferred the main request, so a generic failure there would mask an actionable `OAUTH2_REDIRECT` arriving from the extended-metadata request. Selection now picks whichever response carries a structured `errors[]`, keeping your plain-message fallback intact when neither does. Also covered by a new non-vacuous test.
   
   **3. Correction on my earlier verification note.** I previously said the Jest failures here were environmental (Node 22 vs the required ^24.16.0, `fetch-mock` not intercepting). That was wrong — this worktree simply had no `node_modules`. After a proper install the whole suite runs green on Node 22:
   
   ```
   Tests: 9 passed, 9 total
     ✓ renders columns / indexes / preview
     ✓ renders an OAuth2 authorization prompt when metadata errors with OAUTH2_REDIRECT
     ✓ surfaces an OAUTH2_REDIRECT from the extended metadata request when the main request fails generically
     ✓ repopulates the preview once the OAuth2 dance completes
     ✓ renders the error message when metadata fails without a structured error
     ✓ table actions › refreshes table metadata / shows CREATE VIEW statement
   ```
   
   `src/components/ErrorMessage` also green (14 suites, 69 tests). prettier, oxlint, stylelint and the custom-rules hook pass on the touched files; the pre-commit frontend type-check fails only on `TS6305` "output file has not been built from source" across the whole repo because the workspace `lib/` outputs aren't built locally — zero type errors reference the files in this diff.
   
   The one bot comment I did **not** act on is the unscoped `'TableMetadatas'` invalidation; I replied inline with the reasoning (no resource identity in the OAuth2 error payload, matches the existing unscoped `'Tables'`/`Schemas`/`Catalogs` siblings, and RTK Query only refetches active subscribers — one per pinned table tab). Happy to change course if you disagree.
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #42390:
URL: https://github.com/apache/superset/pull/42390


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5147192196

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5111458005

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42390:
URL: https://github.com/apache/superset/pull/42390#issuecomment-5187205201

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(sqllab): retry table metadata preview after OAuth2 redirect [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42390:
URL: https://github.com/apache/superset/pull/42390#discussion_r3717101506


##########
superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx:
##########
@@ -121,6 +121,7 @@ export function OAuth2RedirectMessage({
             { type: 'Schemas', id: 'LIST' },
             { type: 'Catalogs', id: 'LIST' },
             'Tables',
+            'TableMetadatas',

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > For OAuth2 redirect handling, retain unscoped cache-tag invalidation when the error payload lacks database or table identity; do not require resource-scoped invalidation without threading that identity through the error flow.
   
   **Applied to:**
     - `superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org