Skip to content

fix(home): redirect users without an ID before rendering - #44456

Open
I3eka wants to merge 5 commits into
apache:masterfrom
I3eka:fix-home-anonymous-navigation
Open

I3eka wants to merge 5 commits into
apache:masterfrom
I3eka:fix-home-anonymous-navigation

Conversation

@I3eka

@I3eka I3eka commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Prevent the Home page from crashing when an anonymous or guest user reaches it through client-side navigation, such as clicking the Superset logo from the login page or a public dashboard.

The server's /welcome/ view already redirects users without an ID to login. SPA navigation bypasses that view and mounts Welcome with bootstrap data that has no userId. The component then throws TypeError: Cannot read properties of undefined (reading 'toString') before it can render.

Add a small page-level guard that renders the personalized Home content only when a user ID exists. Otherwise, use the existing full-page redirect helper to request /welcome/, allowing the server to handle login and return navigation. This preserves application-root handling and avoids issuing Home data requests with a missing user ID. Authenticated users retain the existing page and data-loading behavior.

Open issues and PRs were checked for the exception, userId, welcome, and anonymous/unauthenticated navigation before implementing this change. No matching fix was found. Related Home PR #39528 concerns refreshing recent activity after deletion and does not address this crash.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No visual layout changes.

  • Before: the anonymous and guest regression cases fail at userid!.toString() with the reported exception.
  • After: users without an ID are redirected through the server without mounting the personalized page or requesting its charts, dashboards, recent activity, or saved queries.

TESTING INSTRUCTIONS

Manual reproduction:

  1. Open /login/ in a signed-out browser session using the default Home logo target.
  2. Click the Superset logo to navigate to Home through the SPA.
  3. Confirm that the browser returns to login instead of displaying the unexpected-error boundary.
  4. Sign in and confirm that Home still renders its normal panels.
  5. Repeat in a subdirectory deployment; the full-page redirect must retain the application root.

Automated validation performed with Node 24.16.0:

cd superset-frontend
CI=true NODE_ENV=test NODE_OPTIONS=--max-old-space-size=8192 \
  node node_modules/jest/bin/jest.js --runInBand --silent \
  src/pages/Home src/pages/Login src/features/home \
  src/utils/navigationUtils.test.ts \
  src/views/routes.test.tsx

Result after merging master (4cdd680f39) in 7696187823: 15 suites, 245 tests and 2 snapshots passed. A new zero-ID case fails with the previous truthiness guard and passes with the explicit null/undefined check; the normal ID and three missing-ID cases are controls. Both redirect and render reuse the same predicate. The effect-driven assertion awaits the redirect and uses RoutePaths.HOME; separate route and navigation tests retain literal path and subdirectory coverage. The original anonymous/guest cases were also run against the unmodified Home component and reproduced the reported toString exception.

pre-commit run passed on all three changed files, including formatting, linting, custom rules, stylelint, and the targeted TypeScript check. The local package declarations were built before that check:

node node_modules/typescript/bin/tsc --build \
  packages/superset-ui-core \
  packages/superset-ui-chart-controls \
  packages/superset-ui-switchboard

python scripts/translations/check_pot_drift.py also passed after picking up the upstream catalog fix from #44574. The PR diff remains limited to the same three files.

The browser steps above are reproduction instructions, not a claim of a completed browser E2E run. No deployment changes are included.

ADDITIONAL INFORMATION

  • Has associated issue: No matching open issue found.
  • Required feature flags: None.
  • Changes UI: Login redirect replaces the crash for users without an ID; no layout changes.
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Sep 20, 2026
@netlify

netlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7696187
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6abdfa7fd0f68700086b0928
😎 Deploy Preview https://deploy-preview-44456--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 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.

Code Review Agent Run #892167

Actionable Suggestions - 1
  • superset-frontend/src/pages/Home/index.tsx - 1
Additional Suggestions - 1
  • superset-frontend/src/pages/Home/Home.test.tsx - 1
    • Magic route string · Line 186-186
      The test hardcodes `'/welcome/'` while production uses `RoutePaths.HOME` (index.tsx:459). If the route ever changes, this assertion silently diverges from the constant. Reference `RoutePaths.HOME` so the test tracks the same source of truth.
Review Details
  • Files reviewed - 3 · Commit Range: 07c7697..07c7697
    • docs/docs/quickstart.mdx
    • superset-frontend/src/pages/Home/Home.test.tsx
    • superset-frontend/src/pages/Home/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 an incremental AI Review.

  • /review full - 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

Comment thread superset-frontend/src/pages/Home/index.tsx Outdated
@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.68%. Comparing base (4cdd680) to head (7696187).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44456      +/-   ##
==========================================
- Coverage   81.71%   81.68%   -0.04%     
==========================================
  Files        2978     2978              
  Lines      181613   181331     -282     
  Branches    41983    41928      -55     
==========================================
- Hits       148402   148115     -287     
- Misses      30489    30490       +1     
- Partials     2722     2726       +4     
Flag Coverage Δ
javascript 77.12% <100.00%> (-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.

@bito-code-review

bito-code-review Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2577d7

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/pages/Home/index.tsx - 1
    • Duplicated user-id predicate · Line 466-466
      This change replaces the single `hasUserId` predicate (previously used in both the effect and the return, per the removed `return hasUserId ? ...` line) with two equivalent forms: `Boolean(user?.userId)` on line 457 and `user?.userId` on line 466. Keeping one predicate avoids divergence; the inline form on 466 is what narrows `user` for `Welcome`, so drop the alias and use `user?.userId` in the effect.
Review Details
  • Files reviewed - 1 · Commit Range: 07c7697..6594bdc
    • superset-frontend/src/pages/Home/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 an incremental AI Review.

  • /review full - 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

@sadpandajoe
sadpandajoe requested review from kgabryje, rusackas and sadpandajoe and a lite review from Copilot September 21, 2026 17:13

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 3 Low severity

Open (5)
What changed in this PR

Adds a guard to the Home/Welcome page so SPA navigation for anonymous/guest users triggers a full-page server redirect (instead of crashing when userId is missing), and updates tests/docs accordingly.

Changes:

  • Wrap Home with a page-level guard that redirects to the server when userId is missing
  • Add Jest coverage for anonymous/guest/missing-user redirect behavior (and ensure no Home data fetches occur)
  • Document the sign-in requirement / redirect behavior in the quickstart
File Description
superset-frontend/​src/​pages/​Home/​index.tsx Adds a guarded wrapper component that redirects when userId is absent
superset-frontend/​src/​pages/​Home/​Home.test.tsx Mocks redirect and adds test cases for anonymous/guest/missing user behavior
docs/​docs/​quickstart.mdx Notes that personalized Home requires sign-in and redirects from public entrypoints

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread superset-frontend/src/pages/Home/Home.test.tsx Outdated
Comment thread superset-frontend/src/pages/Home/index.tsx Outdated
Comment thread superset-frontend/src/pages/Home/Home.test.tsx Outdated
Comment thread superset-frontend/src/pages/Home/index.tsx Outdated
Comment thread superset-frontend/src/pages/Home/index.tsx Outdated
@rusackas

Copy link
Copy Markdown
Member

Thanks for chasing this down, solid fix for a real crash. CI's green and the Bito thread already got resolved, but a few Copilot comments are still open (the userId truthy check, the redundant hasUserId guard, and possible flakiness in the new effect-driven test). Mind addressing those before this merges? Happy to take another pass after.

@I3eka

I3eka commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@rusackas, addressed the remaining Copilot comments in 319ba78. The zero-ID case independently failed before the change; redirect and render now share one explicit null/undefined check. The test awaits the redirect and uses RoutePaths.HOME, while the separate route/navigation suites still cover the literal path and subdirectory behavior.

The updated head passes 220 tests and 2 snapshots across 14 suites, plus all applicable pre-commit hooks on the complete three-file PR diff. I did not reproduce the suggested scheduling flake (RTL render already uses act), so I am not claiming that as a confirmed bug. New-head CI is still pending and there was no deployment. Could you take the re-review you offered?

CI update: babel-extract fails on the connection-move/OAuth2 warning in messages.pot, not a Home string. The exact missing/stale pair is already covered by open #44547; I am not duplicating its translation changes in this focused Home PR. Other checks are still running, so this head is not CI-green.

@bito-code-review

bito-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f786bf

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6594bdc..319ba78
    • superset-frontend/src/pages/Home/Home.test.tsx
    • superset-frontend/src/pages/Home/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 an incremental AI Review.

  • /review full - 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

@I3eka

I3eka commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@rusackas, could you take another pass? All six original review threads are resolved, including the shared ID-presence guard and the awaited redirect assertion.

I merged current master (e90b9fb751) in 7975fdf652 to pick up #44574. That fixes the stale messages.pot behind the previous babel-extract failure. The PR still changes only the same three files.

Validation on the updated head: 14 suites, 221 tests and 2 snapshots passed; all applicable pre-commit hooks passed, including TypeScript; python scripts/translations/check_pot_drift.py passed. The PR description includes the commands and updated results.

CI update: babel-extract now passes on the new head. The Docker command verification job failed because the GitHub tags API returned HTTP 502 (Server Error). I attempted to rerun only that job, but GitHub rejected the request with HTTP 403 (Must have admin rights to Repository). Could a maintainer rerun that job as well? Other checks are still running.

@rusackas

rusackas commented Oct 1, 2026

Copy link
Copy Markdown
Member

@I3eka Took another pass, this looks solid and all the review threads are resolved. Rerunning the docker-verify job now, that 502 isn't on you. LGTM once CI's green!

@I3eka

I3eka commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the re-review and for handling the rerun, @rusackas. All other CI checks on 7975fdf652 are passing. Once Docker verification is green, could you also submit the approval so this can be merged?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants