Skip to content

fix(frontend): handle null/undefined path in ensureAppRoot#39940

Open
Abdulrehman-PIAIC80387 wants to merge 1 commit intoapache:masterfrom
Abdulrehman-PIAIC80387:fix/ensure-app-root-undefined-39855
Open

fix(frontend): handle null/undefined path in ensureAppRoot#39940
Abdulrehman-PIAIC80387 wants to merge 1 commit intoapache:masterfrom
Abdulrehman-PIAIC80387:fix/ensure-app-root-undefined-39855

Conversation

@Abdulrehman-PIAIC80387
Copy link
Copy Markdown
Contributor

SUMMARY

ensureAppRoot() in superset-frontend/src/utils/pathUtils.ts calls path.startsWith(...) on its input without first checking that path is defined. When a caller (e.g. Menu.tsx rendering the brand link) passes theme.brandLogoHref that is undefined, the entire app crashes during initialization with:

TypeError: Cannot read properties of undefined (reading 'startsWith')

This happens in real-world setups where a user partially overrides THEME_DEFAULT / THEME_DARK in superset_config.py — Python replaces the entire token dict rather than merging, so tokens like brandLogoHref end up unset.

Fix: widen the parameter type to accept null | undefined and fall back to the application root (or '/') when the path is missing. The app stays alive instead of going to a blank screen.

Fixes #39855

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

After:

TESTING INSTRUCTIONS

Add this to superset_config.py:

THEME_DARK = {
    "token": {"brandLogoUrl": "/static/assets/images/superset-logo-horiz.png"},
    "algorithm": "dark",
}
  1. Restart Superset and switch the UI to the Dark theme.
  2. Before the fix: the page is blank and the console shows Cannot read properties of undefined (reading 'startsWith').
  3. After the fix: the page loads normally; the brand link defaults to the application root.

ADDITIONAL INFORMATION

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 7, 2026

Code Review Agent Run #4c3ab1

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/utils/pathUtils.ts - 1
    • Incorrect null check logic · Line 45-45
      The condition `if (!path)` treats empty strings as falsy, but the comment specifies handling only null or undefined. This alters behavior for empty string inputs (e.g., from `ensureAppRoot('')` returning `${applicationRoot()}/` to returning `applicationRoot()`), which may affect usages like `ensureAppRoot(item.url || '')` in RightMenu.tsx.
      Code suggestion
       @@ -44,3 +44,3 @@
      - export function ensureAppRoot(path: string | null | undefined): string {
      -   if (!path) {
      -     return applicationRoot() || '/';
      + export function ensureAppRoot(path: string | null | undefined): string {
      +   if (path == null) {
      +     return applicationRoot() || '/';
Review Details
  • Files reviewed - 1 · Commit Range: 1ab0fba..1ab0fba
    • superset-frontend/src/utils/pathUtils.ts
  • 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

@dosubot dosubot Bot added the change:frontend Requires changing the frontend label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6.1.0rc3] Bug in the "Dark" theme (?)

1 participant