yousoph opened a new pull request, #41913: URL: https://github.com/apache/superset/pull/41913
### SUMMARY Follow-up to #41101, which added OAuth2 retry-after-redirect for the schema-loading (`source='crud'`) path. After completing the OAuth2 dance from the dataset-creation modal, the schema list refreshed but the **"Authorization needed" banner stayed visible**. **Root cause:** the banner is held in local `errorPayload` state in `DatabaseSelector` / `TableSelector`, cleared only by the `useSchemas` / `useCatalogs` `onSuccess` callback. Those hooks fired `onSuccess`/`onError` **only through the lazy `trigger` path** (initial load / force-refresh). The OAuth2 redirect handler in `OAuth2RedirectMessage` dispatches `invalidateTags`, which refetches the **subscribed** query — so the list repopulated but `onSuccess` never fired and the banner lingered. `useTables` already fired its callbacks on subscribed refetch, which is why `TableSelector` never exhibited the bug and needs no change here. **Fix:** in `useSchemas` and `useCatalogs`, fire the success/error callbacks whenever the subscribed query completes a fetch, keyed off the `isFetching` true→false transition. This: - Covers invalidation-driven refetches (fixes the bug). - Avoids re-firing on cache-hit re-renders, which would spuriously re-run the selectors' auto-select logic. - Passes `isRefetched=false` so no "List refreshed" toast fires on the automatic retry. - Uses `useEffectEvent` for stable callback identity, matching the sibling `useTables` hook. ### BEFORE/AFTER | Scenario | Before | After | |---|---|---| | Dataset modal — schema banner after OAuth2 redirect | ❌ list refreshes, banner stays | ✅ banner clears | | Dataset modal — catalog banner after OAuth2 redirect | ❌ banner stays | ✅ banner clears | | SQL Lab / Explore / Dashboard retry | ✅ (unchanged) | ✅ (unchanged) | ### TESTING INSTRUCTIONS 1. Create a DB connection that uses OAuth2. 2. Open the dataset-creation modal and select that DB — you should see the "Authorization needed" banner. 3. Complete the OAuth2 dance in the popup. 4. **Expected:** schemas populate **and** the banner disappears. New/updated tests: - `schemas.test.ts` / new `catalogs.test.ts`: prove `onSuccess`/`onError` fire on the `invalidateTags` subscribed refetch, including error→success recovery (the exact OAuth flow). - `DatabaseSelector.test.tsx`: integration test reproducing the symptom — banner appears, then clears after `invalidateTags`. (Verified it fails against the pre-fix hook.) ### ADDITIONAL INFORMATION - [ ] Has associated issue - [x] Required feature flags: n/a - [ ] Changes UI - [ ] Introduces new feature or API - [x] Removes existing feature or API Follow-up to #41101. 🤖 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]
