I3eka opened a new pull request, #44456:
URL: https://github.com/apache/superset/pull/44456
### 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 and npm 11.13.0:
```sh
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/Home.test.tsx \
src/pages/Home/Home.mobile.test.tsx \
src/utils/navigationUtils.test.ts \
src/views/routes.test.tsx
```
Result: **4 suites, 107 tests passed**. The new 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:
```sh
node node_modules/typescript/bin/tsc --build \
packages/superset-ui-core \
packages/superset-ui-chart-controls \
packages/superset-ui-switchboard
```
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.
- [x] 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
--
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]