Skip to content

fix(dataset): retry metadata after OAuth2 authorization - #42581

Merged
aminghadersohi merged 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/dataset-creation-oauth2-retry
Aug 1, 2026
Merged

fix(dataset): retry metadata after OAuth2 authorization#42581
aminghadersohi merged 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/dataset-creation-oauth2-retry

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

The dataset-creation metadata preview now preserves structured API errors and renders them through the registered error-message system, so OAuth2 authorization failures display the existing authorization prompt instead of a generic empty error state.

After a matching OAuth2 completion notification, the preview retries only its original table-metadata request. This keeps the existing raw SupersetClient call rather than migrating a single request to RTK Query, avoiding a larger change and broad cache invalidation of unrelated metadata requests. The shared OAuth2 component now accepts the existing optional mitigation callback and deduplicates the BroadcastChannel and storage notifications emitted for the same tab.

The blast radius is limited to dataset creation and the optional callback path in the shared OAuth2 message; SQL Lab, Explore, dashboard, and default CRUD retry behavior are unchanged when no callback is supplied. Request IDs prevent stale or unmounted requests from updating the preview. Rollback is a revert of this commit.

Review guidance: start with DatasetPanel/index.tsx for error parsing and scoped retry, then follow errorMitigationFunction through ErrorMessageWithStackTrace into OAuth2RedirectMessage.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not included because a local Superset backend was unavailable. The UI uses the existing OAuth2 authorization alert, and React Testing Library coverage verifies the authorization link and successful automatic retry.

TESTING INSTRUCTIONS

  1. Configure a database that uses OAuth2 authentication.
  2. In the dataset-creation flow, select a table whose metadata request requires authorization.
  3. Verify the authorization alert and link are displayed.
  4. Complete authorization in the opened tab and verify the selected table's columns load automatically without reselecting the table.

Automated validation:

cd superset-frontend
npm run test -- \
  src/components/ErrorMessage/ErrorMessageWithStackTrace.test.tsx \
  src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx \
  src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.test.tsx \
  src/features/datasets/AddDataset/DatasetPanel/DatasetPanelWrapper.test.tsx \
  src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.subdirectory.test.tsx \
  src/features/datasets/DatasetLayout/DatasetLayout.test.tsx

All 6 suites and 37 tests pass. Scoped Prettier, Oxlint, custom frontend rules, and stylelint checks pass. The targeted type-check hook could not complete locally because the clean worktree lacks built workspace declaration outputs (TS6305); CI builds those package outputs.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.70732% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.34%. Comparing base (673f928) to head (ed141c1).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...eatures/datasets/AddDataset/DatasetPanel/index.tsx 74.57% 15 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42581   +/-   ##
=======================================
  Coverage   65.33%   65.34%           
=======================================
  Files        2803     2803           
  Lines      158490   158523   +33     
  Branches    36178    36190   +12     
=======================================
+ Hits       103557   103589   +32     
- Misses      52922    52923    +1     
  Partials     2011     2011           
Flag Coverage Δ
javascript 71.48% <81.70%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi
aminghadersohi marked this pull request as ready for review July 30, 2026 04:22
@dosubot dosubot Bot added authentication:sso Single Sign On change:frontend Requires changing the frontend data:dataset Related to dataset configurations labels Jul 30, 2026
@aminghadersohi
aminghadersohi requested a review from yousoph July 30, 2026 04:23
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current implementation relies on clientError.error as a fallback, which can be undefined if getClientErrorObject returns a response without an explicit error field (e.g., network failures or non-JSON responses).

To resolve this, you should update the error handling logic to prioritize clientError.message or clientError.statusText and provide a localized fallback string, similar to how CRUD error handling is implemented elsewhere in the codebase.

Here is a concise fix for the error handling block in superset-frontend/src/features/datasets/AddDataset/DatasetPanel/index.tsx:

const parsedError = clientError.errors?.[0] ?? {
  error_type: ErrorTypeEnum.GENERIC_BACKEND_ERROR,
  extra: null,
  level: 'error' as const,
  message: clientError.message || clientError.statusText || t('An unexpected error occurred'),
};

Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

superset-frontend/src/features/datasets/AddDataset/DatasetPanel/index.tsx

const parsedError = clientError.errors?.[0] ?? {
  error_type: ErrorTypeEnum.GENERIC_BACKEND_ERROR,
  extra: null,
  level: 'error' as const,
  message: clientError.message || clientError.statusText || t('An unexpected error occurred'),
};

@aminghadersohi
aminghadersohi requested review from rebenitez1802 and removed request for yousoph July 30, 2026 04:27
@bito-code-review

bito-code-review Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4d356d

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx - 1
    • Missing test for deduplication guard · Line 111-118
      The new `lastHandledTabIdRef` deduplication guard on line 111 has no unit test coverage. The existing test at `OAuth2RedirectMessage.test.tsx:238` checks that `errorMitigationFunction` is called once, but does not independently verify that a second matching message (e.g., storage event after the broadcast) is deduplicated and does not trigger additional dispatches.
Review Details
  • Files reviewed - 12 · Commit Range: 987bdf8..f29c628
    • superset-frontend/src/components/ErrorMessage/ErrorMessageWithStackTrace.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
    • superset-frontend/src/components/ErrorMessage/types.ts
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.stories.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.subdirectory.test.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.test.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanelWrapper.test.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/MessageContent.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/index.tsx
    • superset-frontend/src/features/datasets/DatasetLayout/DatasetLayout.test.tsx
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes — one robustness regression to guard before merge.

Nice fix overall — the OAuth2 retry, the request-ID race guard, and the BroadcastChannel/storage dedup all look sound, and the coverage is good. One blocking item:

Catch-block fallback can pass message: undefined into a component that crashes on it.

When table_metadata rejects with a non-2xx JSON body that has no structured errors[] and no usable error/message (e.g. {} or { "errors": [] }), getClientErrorObjectparseErrorJson returns error: undefined — it's typed string, but the final return { ...error, error: error.error } propagates undefined. The catch fallback then builds { error_type: GENERIC_BACKEND_ERROR, extra: null, level: 'error', message: undefined }.

Because that fallback pins error_type: GENERIC_BACKEND_ERROR, ErrorMessageWithStackTrace routes it through the registry to DatabaseErrorMessage (setupErrorMessages.ts), which does message.split('\n') with no guard (DatabaseErrorMessage.tsx) → TypeError during render, blanking the dataset preview. Pre-PR, this same input rendered the benign "Unable to load columns" MessageContent, so it's a regression from a soft error state to a hard render crash.

One-line guard suggested inline below. Everything else I found was low-severity (test gaps for the stale-response/deselect paths and the second-tab_id dedup round; the errorMitigationFunction naming vs the onX convention; a duplicated generic-error literal) and is non-blocking — happy to share those separately if useful.

Comment thread superset-frontend/src/features/datasets/AddDataset/DatasetPanel/index.tsx Outdated
@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit fdea5b3
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a6b97656eff5a0008f22715
😎 Deploy Preview https://deploy-preview-42581--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #24ac66

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: f29c628..ed141c1
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.test.tsx
    • superset-frontend/src/components/ErrorMessage/OAuth2RedirectMessage.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanelWrapper.test.tsx
    • superset-frontend/src/features/datasets/AddDataset/DatasetPanel/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aminghadersohi
aminghadersohi merged commit 22c305f into apache:master Aug 1, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication:sso Single Sign On change:frontend Requires changing the frontend data:dataset Related to dataset configurations size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants