You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rebenitez1802 (via GitHub)" <gi...@apache.org> on 2026/01/12 15:28:32 UTC
[PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
rebenitez1802 opened a new pull request, #37059:
URL: https://github.com/apache/superset/pull/37059
### SUMMARY
Fixes #34865 where APP_NAME configuration stopped working for browser window/tab titles after the Ant Design v5 theme migration in Superset 6.0.
**Changes:**
- Added `brandAppName` theme token for application name in window titles
- Implemented 3-tier fallback: `brandAppName` → `APP_NAME` config → `"Superset"`
- Updated frontend title cleanup to use theme token instead of hardcoded "Superset"
- Applied fallback to bootstrap payload so React components receive correct value
**Backward compatibility:** Existing `APP_NAME` configurations continue to work automatically via fallback mechanism.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Window title always shows "Superset" regardless of `APP_NAME` config
**After:** Window title shows configured `APP_NAME` value (e.g., "My Test Analytics Platform")
### TESTING INSTRUCTIONS
1. Set `APP_NAME = "Custom App Name"` in `superset_config.py`
2. Start Superset and navigate to login page
3. Verify browser tab shows "Custom App Name" instead of "Superset"
4. Navigate to a dashboard/chart, verify title changes to dashboard name
5. Navigate away, verify title returns to "Custom App Name"
**Or test with new theme system:**
```python
THEME_DEFAULT = {
"token": {
"brandAppName": "My Custom Analytics",
}
}
```
### ADDITIONAL INFORMATION
- [x] Has associated issue: #34865
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] 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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739152690
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ac6d68ec8dc6fedeba663990f6f32724841aeba0 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/696513216dd6f600081a280e |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-37059--superset-docs-preview.netlify.app](https://deploy-preview-37059--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-37059--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #37059:
URL: https://github.com/apache/superset/pull/37059#discussion_r2691887358
##########
superset-frontend/oxlint.json:
##########
@@ -14,7 +14,7 @@
},
"settings": {
"react": {
- "version": "detect"
+ "version": "17.0"
Review Comment:
This change from "detect" to a hardcoded version "17.0" appears unrelated to the PR's purpose of migrating APP_NAME to brandAppName. This change should be removed or explained in the PR description if it's intentional and necessary.
```suggestion
"version": "detect"
```
##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -210,14 +210,25 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: PageProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [readyToRender]);
+ // Update document title when dashboard title changes
useEffect(() => {
if (dashboard_title) {
document.title = dashboard_title;
}
+ }, [dashboard_title]);
+
+ // Restore original title on unmount (run once)
+ useEffect(() => {
+ const originalTitle = document.title;
return () => {
- document.title = 'Superset';
+ document.title =
+ originalTitle ||
+ theme?.brandAppName ||
+ theme?.brandLogoAlt ||
+ 'Superset';
};
- }, [dashboard_title]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
Review Comment:
The new title restoration logic on component unmount lacks test coverage. Since this repository has comprehensive test coverage for dashboard components, consider adding tests to verify:
1. Title is set when dashboard_title changes
2. Title is restored to the app name on unmount
3. Fallback chain works correctly (originalTitle → brandAppName → brandLogoAlt → 'Superset')
##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -210,14 +210,25 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: PageProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [readyToRender]);
+ // Update document title when dashboard title changes
useEffect(() => {
if (dashboard_title) {
document.title = dashboard_title;
}
+ }, [dashboard_title]);
+
+ // Restore original title on unmount (run once)
+ useEffect(() => {
+ const originalTitle = document.title;
return () => {
- document.title = 'Superset';
+ document.title =
+ originalTitle ||
+ theme?.brandAppName ||
+ theme?.brandLogoAlt ||
+ 'Superset';
};
- }, [dashboard_title]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
Review Comment:
The title restoration logic has a flaw. The cleanup function captures `originalTitle` at mount time, which could be the title from a previous page navigation. The fallback chain (`originalTitle || theme?.brandAppName || ...`) will only reach the theme values if `originalTitle` is empty/undefined, but it will typically have some value from navigation. This means the theme-based fallback won't work as intended.
Consider capturing the intended app name title at mount instead, or restructuring to restore to the app name directly without relying on the mount-time title.
##########
UPDATING.md:
##########
@@ -128,6 +128,28 @@ See `superset/mcp_service/PRODUCTION.md` for deployment guides.
- [35062](https://github.com/apache/superset/pull/35062): Changed the function signature of `setupExtensions` to `setupCodeOverrides` with options as arguments.
### Breaking Changes
+- [#34865](https://github.com/apache/superset/issues/34865): The `APP_NAME` configuration variable no longer controls the browser window/tab title or other frontend branding. Application names should now be configured using the theme system with the `brandAppName` token. The `APP_NAME` config is still used for backend contexts (MCP service, logs, etc.) and serves as a fallback if `brandAppName` is not set.
+ - **Migration:**
+ ```python
+ # Before (Superset 5.x)
+ APP_NAME = "My Custom App"
+
+ # After (Superset 6.x) - Option 1: Use theme system (recommended)
+ THEME_DEFAULT = {
+ "token": {
+ "brandAppName": "My Custom App", # Window titles
+ "brandLogoAlt": "My Custom App", # Logo alt text
+ "brandLogoUrl": "/static/assets/images/custom_logo.png"
+ }
+ }
+
+ # After (Superset 6.x) - Option 2: Temporary fallback
+ # Keep APP_NAME for now (will be used as fallback for brandAppName)
+ APP_NAME = "My Custom App"
+ # But you should migrate to THEME_DEFAULT.token.brandAppName
+ ```
+ - **Note:** For dark mode, set the same tokens in `THEME_DARK` configuration.
Review Comment:
The documentation states this is a "Breaking Change", but the PR description emphasizes "Backward compatibility: Existing `APP_NAME` configurations continue to work automatically via fallback mechanism." These statements appear contradictory. If backward compatibility is maintained through the fallback, it's not technically a breaking change. Consider either moving this to a non-breaking changes section with a note about migration recommendations, or clarifying what specifically breaks.
##########
superset-frontend/src/explore/components/ExploreViewContainer/index.jsx:
##########
@@ -292,14 +292,25 @@ function ExploreViewContainer(props) {
const theme = useTheme();
+ // Update document title when slice name changes
useEffect(() => {
if (props.sliceName) {
document.title = props.sliceName;
}
+ }, [props.sliceName]);
+
+ // Restore original title on unmount (run once)
+ useEffect(() => {
+ const originalTitle = document.title;
return () => {
- document.title = 'Superset';
+ document.title =
+ originalTitle ||
+ theme?.brandAppName ||
+ theme?.brandLogoAlt ||
+ 'Superset';
};
- }, [props.sliceName]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
Review Comment:
The new title restoration logic on component unmount lacks test coverage. Since this repository has comprehensive test files for this component (ExploreViewContainer.test.tsx exists), consider adding tests to verify:
1. Title is set when sliceName changes
2. Title is restored to the app name on unmount
3. Fallback chain works correctly (originalTitle → brandAppName → brandLogoAlt → 'Superset')
##########
superset-frontend/src/explore/components/ExploreViewContainer/index.jsx:
##########
@@ -292,14 +292,25 @@ function ExploreViewContainer(props) {
const theme = useTheme();
+ // Update document title when slice name changes
useEffect(() => {
if (props.sliceName) {
document.title = props.sliceName;
}
+ }, [props.sliceName]);
+
+ // Restore original title on unmount (run once)
+ useEffect(() => {
+ const originalTitle = document.title;
return () => {
- document.title = 'Superset';
+ document.title =
+ originalTitle ||
+ theme?.brandAppName ||
+ theme?.brandLogoAlt ||
+ 'Superset';
};
- }, [props.sliceName]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
Review Comment:
The title restoration logic has a flaw. The cleanup function captures `originalTitle` at mount time, which could be the title from a previous page navigation. The fallback chain (`originalTitle || theme?.brandAppName || ...`) will only reach the theme values if `originalTitle` is empty/undefined, but it will typically have some value from navigation. This means the theme-based fallback won't work as intended.
Consider capturing the intended app name title at mount instead, or restructuring to restore to the app name directly without relying on the mount-time title.
##########
superset/views/base.py:
##########
@@ -567,10 +568,39 @@ def get_spa_template_context(
"""
payload = get_spa_payload(extra_bootstrap_data)
- # Extract theme data for template access
- theme_data = get_theme_bootstrap_data().get("theme", {})
+ # Deep copy theme data to avoid mutating cached bootstrap payload
+ theme_data = copy.deepcopy(payload.get("common", {}).get("theme", {}))
default_theme = theme_data.get("default", {})
- theme_tokens = default_theme.get("token", {})
+ dark_theme = theme_data.get("dark", {})
+
+ # Apply brandAppName fallback to both default and dark themes
+ # Priority: theme brandAppName > APP_NAME config > "Superset" default
+ app_name_from_config = app.config.get("APP_NAME", "Superset")
+ for theme_config in [default_theme, dark_theme]:
+ if not theme_config:
+ continue
+ # Get or create token dict
+ if "token" not in theme_config:
+ theme_config["token"] = {}
+ theme_tokens = theme_config["token"]
+
+ if (
+ not theme_tokens.get("brandAppName")
+ or theme_tokens.get("brandAppName") == "Superset"
+ ):
+ # If brandAppName not set or is default, check if APP_NAME customized
+ if app_name_from_config != "Superset":
+ # User has customized APP_NAME, use it as brandAppName
+ theme_tokens["brandAppName"] = app_name_from_config
+
+ # Write the modified theme data back to payload
+ if "common" not in payload:
+ payload["common"] = {}
+ payload["common"]["theme"] = theme_data
Review Comment:
The code attempts to avoid mutating cached data by deep copying `theme_data`, but then modifies `payload["common"]["theme"]` directly on line 599. Since `payload["common"]` is a reference to the cached bootstrap data (returned from `common_bootstrap_payload()`), this assignment mutates the cached dictionary structure. While the theme data itself is a copy, the cached dict's structure is being modified.
To fix this properly, you should also deep copy `payload["common"]` before modifying it, or restructure to avoid mutation entirely.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739166780
CodeAnt AI finished reviewing your PR.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3747188558
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #37059:
URL: https://github.com/apache/superset/pull/37059#discussion_r2682798793
##########
superset-frontend/src/explore/components/ExploreViewContainer/index.jsx:
##########
@@ -297,9 +297,9 @@ function ExploreViewContainer(props) {
document.title = props.sliceName;
}
return () => {
- document.title = 'Superset';
+ document.title = theme.brandAppName || theme.brandLogoAlt || 'Superset';
};
- }, [props.sliceName]);
+ }, [props.sliceName, theme.brandAppName, theme.brandLogoAlt]);
Review Comment:
**Suggestion:** The effect dependency list references nested `theme` properties (`theme.brandAppName`, `theme.brandLogoAlt`) which will evaluate those property accesses on every render and can throw if `theme` is undefined; prefer depending on the `theme` object itself so the effect reruns when the theme changes and you avoid direct property access in the dependency array. [possible bug]
**Severity Level:** Critical 🚨
```suggestion
}, [props.sliceName, theme]);
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
Depending on the whole `theme` object avoids accessing nested properties during dependency evaluation (which could throw if `theme` were undefined) and ensures the effect re-runs when the theme reference changes. It's a reasonable change; the trade-off of rerunning on any theme property change is acceptable here because the effect is simply setting document.title.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
**Line:** 302:302
**Comment:**
*Possible Bug: The effect dependency list references nested `theme` properties (`theme.brandAppName`, `theme.brandLogoAlt`) which will evaluate those property accesses on every render and can throw if `theme` is undefined; prefer depending on the `theme` object itself so the effect reruns when the theme changes and you avoid direct property access in the dependency array.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset-frontend/src/explore/components/ExploreViewContainer/index.jsx:
##########
@@ -297,9 +297,9 @@ function ExploreViewContainer(props) {
document.title = props.sliceName;
}
return () => {
- document.title = 'Superset';
+ document.title = theme.brandAppName || theme.brandLogoAlt || 'Superset';
Review Comment:
**Suggestion:** Accessing nested properties on `theme` without guarding for `theme` being undefined can throw a TypeError (cannot read property 'brandAppName' of undefined). Use optional chaining when reading `theme` properties and make the effect depend on the `theme` object (not its nested properties) to avoid runtime errors and stale/incorrect dependency evaluations. [null pointer]
**Severity Level:** Minor ⚠️
```suggestion
document.title = theme?.brandAppName || theme?.brandLogoAlt || 'Superset';
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
This is a small, defensive improvement: guarding with optional chaining prevents a possible TypeError if `theme` were ever undefined at runtime. `useTheme()` usually returns a theme object, so this is unlikely to be required, but the change is harmless and reduces risk with no functional downside.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
**Line:** 300:300
**Comment:**
*Null Pointer: Accessing nested properties on `theme` without guarding for `theme` being undefined can throw a TypeError (cannot read property 'brandAppName' of undefined). Use optional chaining when reading `theme` properties and make the effect depend on the `theme` object (not its nested properties) to avoid runtime errors and stale/incorrect dependency evaluations.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset/templates/superset/spa.html:
##########
@@ -24,6 +24,8 @@
{% block title %}
{% if title %}
{{ title }}
+ {% else %}
+ {{ default_title }}
Review Comment:
**Suggestion:** The template uses a manual if/else for `title` vs `default_title`; prefer Jinja's `default` filter to handle undefined/empty `default_title` in a concise, reliable way so empty strings or undefined values fall back to the app config. [logic error]
**Severity Level:** Minor ⚠️
```suggestion
{{ default_title | default(appbuilder.app.config.get('APP_NAME', '')) }}
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
Using the `default` filter is a concise, idiomatic Jinja solution that covers undefined or empty values and can fall back to the app name. It improves correctness and readability compared to manually checking elsewhere.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/templates/superset/spa.html
**Line:** 28:28
**Comment:**
*Logic Error: The template uses a manual if/else for `title` vs `default_title`; prefer Jinja's `default` filter to handle undefined/empty `default_title` in a concise, reliable way so empty strings or undefined values fall back to the app config.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -215,9 +215,9 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: PageProps) => {
document.title = dashboard_title;
}
return () => {
- document.title = 'Superset';
+ document.title = theme.brandAppName || theme.brandLogoAlt || 'Superset';
};
- }, [dashboard_title]);
+ }, [dashboard_title, theme.brandAppName, theme.brandLogoAlt]);
Review Comment:
**Suggestion:** The current effect's cleanup runs on every dependency change, which causes a brief title reset/flicker between cleanup and the next effect run; separate concerns into two effects—one that updates title when `dashboard_title` changes, and one (mounted once) that captures and restores the original title on unmount—to avoid unnecessary cleanup runs on re-renders. [logic error]
**Severity Level:** Minor ⚠️
```suggestion
useEffect(() => {
if (dashboard_title) {
document.title = dashboard_title;
}
}, [dashboard_title]);
useEffect(() => {
const originalTitle = document.title;
return () => {
document.title = originalTitle || theme?.brandAppName || theme?.brandLogoAlt || 'Superset';
};
}, []);
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
This is the correct direction: separate concerns into a short-lived effect
that updates the title when `dashboard_title` changes and a mount-only
effect that captures/restores the original document.title on unmount.
That prevents the cleanup from running on every dependency change (which
causes flicker) and ensures the original title is preserved once the
component unmounts.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/containers/DashboardPage.tsx
**Line:** 215:220
**Comment:**
*Logic Error: The current effect's cleanup runs on every dependency change, which causes a brief title reset/flicker between cleanup and the next effect run; separate concerns into two effects—one that updates title when `dashboard_title` changes, and one (mounted once) that captures and restores the original title on unmount—to avoid unnecessary cleanup runs on re-renders.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
tests/unit_tests/views/test_base_theme_helpers.py:
##########
@@ -530,3 +530,175 @@ def test_ui_admin_disabled_no_config_themes(self, mock_get_config, mock_app):
assert result["theme"]["enableUiThemeAdministration"] is False
assert result["theme"]["default"] == {}
assert result["theme"]["dark"] == {}
+
+
+class TestBrandAppNameFallback:
+ """Test brandAppName fallback mechanism for APP_NAME migration (issue #34865)"""
+
+ @patch("superset.views.base.get_spa_payload")
+ @patch("superset.views.base.app")
+ def test_brandappname_uses_theme_value_when_set(
+ self, mock_app, mock_payload
+ ):
+ """Test that explicit brandAppName in theme takes precedence"""
+ from superset.views.base import get_spa_template_context
+
+ mock_app.config = MagicMock()
+ mock_app.config.get.side_effect = lambda k, d=None: {
+ "APP_NAME": "Fallback App Name",
+ }.get(k, d)
Review Comment:
**Suggestion:** Tests set up the patched `app` as a MagicMock and then configure `mock_app.config.get.side_effect` via a lambda; this is more verbose and error-prone than using a real dict-like config object. Replace the MagicMock-based config with a plain mapping (dict) so that `app.config.get("APP_NAME", "Superset")` behaves identically to runtime and the test is clearer and less brittle. [possible bug]
**Severity Level:** Critical 🚨
```suggestion
# Use a plain dict for config to mirror Flask's config mapping behavior
mock_app.config = {"APP_NAME": "Fallback App Name"}
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
Replacing the MagicMock-based config with a plain dict is a reasonable improvement: it better mirrors Flask's config mapping (which exposes .get) and is less brittle than fiddling with side_effect. The change is low-risk and improves clarity of the test.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/views/test_base_theme_helpers.py
**Line:** 546:549
**Comment:**
*Possible Bug: Tests set up the patched `app` as a MagicMock and then configure `mock_app.config.get.side_effect` via a lambda; this is more verbose and error-prone than using a real dict-like config object. Replace the MagicMock-based config with a plain mapping (dict) so that `app.config.get("APP_NAME", "Superset")` behaves identically to runtime and the test is clearer and less brittle.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset/views/base.py:
##########
@@ -567,9 +567,28 @@ def get_spa_template_context(
"""
payload = get_spa_payload(extra_bootstrap_data)
- # Extract theme data for template access
- theme_data = get_theme_bootstrap_data().get("theme", {})
+ # Extract theme data from payload (this is what gets sent to frontend)
+ theme_data = payload.get("common", {}).get("theme", {})
default_theme = theme_data.get("default", {})
+ dark_theme = theme_data.get("dark", {})
+
+ # Apply brandAppName fallback to both default and dark themes
+ # Priority: theme brandAppName > APP_NAME config > "Superset" default
+ app_name_from_config = app.config.get("APP_NAME", "Superset")
+ for theme_config in [default_theme, dark_theme]:
+ if not theme_config:
+ continue
+ theme_tokens = theme_config.get("token", {})
Review Comment:
**Suggestion:** When a theme has no "token" key the code creates a local token dict but never assigns it back to the theme config, so the fallback `brandAppName` is not persisted into the theme structure; ensure you create and assign the `token` dict into `theme_config` before mutating it. [logic error]
**Severity Level:** Minor ⚠️
```suggestion
theme_tokens = theme_config.get("token")
if theme_tokens is None:
# Ensure we persist a token dict back into the theme config so mutations are retained
theme_tokens = {}
theme_config["token"] = theme_tokens
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
If a theme_config lacks a "token" key, theme_config.get("token", {}) returns a fresh dict that is not attached back to theme_config.
Mutating that local dict will not persist the fallback into the theme structure, so later reads (e.g., theme_tokens = default_theme.get("token", {})) won't see the brandAppName.
Assigning the dict back (theme_config["token"] = theme_tokens) or ensuring token exists before mutation fixes the logic bug.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/views/base.py
**Line:** 581:581
**Comment:**
*Logic Error: When a theme has no "token" key the code creates a local token dict but never assigns it back to the theme config, so the fallback `brandAppName` is not persisted into the theme structure; ensure you create and assign the `token` dict into `theme_config` before mutating it.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset/views/base.py:
##########
@@ -567,9 +567,28 @@ def get_spa_template_context(
"""
payload = get_spa_payload(extra_bootstrap_data)
- # Extract theme data for template access
- theme_data = get_theme_bootstrap_data().get("theme", {})
+ # Extract theme data from payload (this is what gets sent to frontend)
+ theme_data = payload.get("common", {}).get("theme", {})
default_theme = theme_data.get("default", {})
+ dark_theme = theme_data.get("dark", {})
Review Comment:
**Suggestion:** The code mutates the theme dicts taken from the cached bootstrap payload in-place, which will modify the memoized cached object shared across requests and cause state leakage/race conditions; make deep copies of the theme dicts before mutating them. [race condition]
**Severity Level:** Minor ⚠️
```suggestion
import copy
theme_data = payload.get("common", {}).get("theme", {})
default_theme = copy.deepcopy(theme_data.get("default", {}) or {})
dark_theme = copy.deepcopy(theme_data.get("dark", {}) or {})
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
The payload's "common" value comes from a memoized function (cached_common_bootstrap_data).
Mutating dicts taken from that cached structure in-place will leak state across requests and
can cause surprising/racy behavior. Deep-copying the theme dicts before modifying them fixes
the root cause. The suggestion is accurate and directly addresses a real shared-state bug.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/views/base.py
**Line:** 572:573
**Comment:**
*Race Condition: The code mutates the theme dicts taken from the cached bootstrap payload in-place, which will modify the memoized cached object shared across requests and cause state leakage/race conditions; make deep copies of the theme dicts before mutating them.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset-frontend/packages/superset-core/src/ui/theme/types.ts:
##########
@@ -119,6 +119,7 @@ export interface SupersetSpecificTokens {
// Brand-related
brandIconMaxWidth: number;
+ brandAppName: string;
Review Comment:
**Suggestion:** Breaking change / required property: adding `brandAppName: string` as a required property will break existing theme objects and consumers that don't provide this token (TypeScript errors at compile time and runtime `undefined` where code expects a string). Make the new token optional to preserve backward compatibility. [type error]
**Severity Level:** Minor ⚠️
```suggestion
brandAppName?: string;
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
The PR introduced a new required token (brandAppName: string) which is a breaking
change for existing theme objects. Making it optional prevents immediate
TypeScript/consumer breakage and is the least invasive compatibility fix.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/packages/superset-core/src/ui/theme/types.ts
**Line:** 122:122
**Comment:**
*Type Error: Breaking change / required property: adding `brandAppName: string` as a required property will break existing theme objects and consumers that don't provide this token (TypeScript errors at compile time and runtime `undefined` where code expects a string). Make the new token optional to preserve backward compatibility.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
##########
superset/views/base.py:
##########
@@ -581,13 +600,17 @@ def get_spa_template_context(
# No custom URL either, use default SVG
spinner_svg = get_default_spinner_svg()
+ # Determine default title using the (potentially updated) brandAppName
+ default_title = theme_tokens.get("brandAppName", "Superset")
Review Comment:
**Suggestion:** `default_title` is derived only from the default theme token; if the default theme lacks a brand name but the dark theme has one (or APP_NAME is customized), the title will incorrectly fall back to "Superset"; pick the title from default token, then dark token, then APP_NAME config, then "Superset". [logic error]
**Severity Level:** Minor ⚠️
```suggestion
default_title = (
theme_tokens.get("brandAppName")
or dark_theme.get("token", {}).get("brandAppName")
or app.config.get("APP_NAME", "Superset")
or "Superset"
)
```
<details>
<summary><b>Why it matters? ⭐ </b></summary>
Reading only the default theme token can miss a valid brand name present in the dark theme or the APP_NAME config.
The proposed fallback chain (default token -> dark token -> APP_NAME config -> "Superset") is reasonable and fixes a visible UX inconsistency where the title falls back to "Superset" even though a brand name exists elsewhere.
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/views/base.py
**Line:** 604:604
**Comment:**
*Logic Error: `default_title` is derived only from the default theme token; if the default theme lacks a brand name but the dark theme has one (or APP_NAME is customized), the title will incorrectly fall back to "Superset"; pick the title from default token, then dark token, then APP_NAME config, then "Superset".
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
```
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3747056378
CodeAnt AI is running Incremental review
---
### Thanks for using CodeAnt! 🎉
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ·
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ·
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739186976
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/37059?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `54.54545%` with `5 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.28%. Comparing base ([`84279ac`](https://app.codecov.io/gh/apache/superset/commit/84279acd2fb9a8c87a5534c788ba6e86dd84b414?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ac6d68e`](https://app.codecov.io/gh/apache/superset/commit/ac6d68ec8dc6fedeba663990f6f32724841aeba0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 34 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/37059?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/views/base.py](https://app.codecov.io/gh/apache/superset/pull/37059?src=pr&el=tree&filepath=superset%2Fviews%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvYmFzZS5weQ==) | 54.54% | [2 Missing and 3 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/37059?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #37059 +/- ##
===========================================
+ Coverage 0 48.28% +48.28%
===========================================
Files 0 642 +642
Lines 0 47934 +47934
Branches 0 5238 +5238
===========================================
+ Hits 0 23143 +23143
- Misses 0 24132 +24132
- Partials 0 659 +659
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/37059/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/37059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `42.91% <54.54%> (?)` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/37059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `46.49% <54.54%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/37059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.27% <54.54%> (?)` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/37059/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/37059?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739138209
CodeAnt AI is reviewing your PR.
---
### Thanks for using CodeAnt! 🎉
We're free for open-source projects. if you're enjoying it, help us grow by sharing.
[Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ·
[Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ·
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739138563
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739579112
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #37059:
URL: https://github.com/apache/superset/pull/37059#discussion_r2688478140
##########
tests/unit_tests/views/test_base_theme_helpers.py:
##########
@@ -530,3 +530,175 @@ def test_ui_admin_disabled_no_config_themes(self, mock_get_config, mock_app):
assert result["theme"]["enableUiThemeAdministration"] is False
assert result["theme"]["default"] == {}
assert result["theme"]["dark"] == {}
+
+
+class TestBrandAppNameFallback:
+ """Test brandAppName fallback mechanism for APP_NAME migration (issue #34865)"""
+
+ @patch("superset.views.base.get_spa_payload")
+ @patch("superset.views.base.app")
+ def test_brandappname_uses_theme_value_when_set(
+ self, mock_app, mock_payload
+ ):
+ """Test that explicit brandAppName in theme takes precedence"""
+ from superset.views.base import get_spa_template_context
+
+ mock_app.config = MagicMock()
+ mock_app.config.get.side_effect = lambda k, d=None: {
+ "APP_NAME": "Fallback App Name",
+ }.get(k, d)
Review Comment:
Let's do this ^
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3739156598
## Nitpicks 🔍
<table>
<tr><td>🔒 <strong>No security issues identified</strong></td></tr>
<tr><td>⚡ <strong>Recommended areas for review</strong><br><br>
- [ ] <a href='https://github.com/apache/superset/pull/37059/files#diff-8a676fb002920d1d142fa9b19ded1ecb7b8b8d682cf9b9fe80f01b1a2314c86dR570-R587'><strong>Cached data mutation</strong></a><br>The code mutates theme dictionaries obtained from the cached bootstrap payload (via `payload.get("common")`). Because `cached_common_bootstrap_data` is memoized, modifying those dicts in-place can persist changes across requests and users, causing cross-request contamination. Confirm that mutations are performed on a copy instead of the cached object.<br>
- [ ] <a href='https://github.com/apache/superset/pull/37059/files#diff-8a676fb002920d1d142fa9b19ded1ecb7b8b8d682cf9b9fe80f01b1a2314c86dR578-R592'><strong>Token not persisted</strong></a><br>The code reads `theme_config.get("token", {})` and mutates the returned dict, but if the `token` key did not previously exist this mutating dict is not written back into `theme_config`. As a result the fallback `brandAppName` may not be persisted into the theme structure sent to templates/bootstrap payload.<br>
- [ ] <a href='https://github.com/apache/superset/pull/37059/files#diff-c99ae4b2b09b756ab2189a99a9685229f9d12633fc2616c368ea869770f603bfR780-R782'><strong>Backward compatibility</strong></a><br>THEME_DEFAULT["token"]["brandAppName"] is set at module import time to the current value of `APP_NAME`. User overrides from a later-imported `superset_config` (applied at the end of this file) will update `APP_NAME` but will not update THEME_DEFAULT, so the theme token may not reflect user-specified `APP_NAME`. Verify that the intended 3-tier fallback and backward compatibility work when `APP_NAME` is overridden in a local config.<br>
- [ ] <a href='https://github.com/apache/superset/pull/37059/files#diff-449931f1bf449596ce5e3ab49828ee91c5fc3532cf191e4dbd44fff4ba779c61R121-R123'><strong>Breaking Type Change</strong></a><br>Making `brandAppName` a required property on `SupersetSpecificTokens` means the combined `SupersetTheme` type now requires this field. Existing theme objects or serialized theme payloads that don't provide `brandAppName` will fail type-checking or cause runtime assumptions elsewhere. Verify that all theme producers (bootstrap payload, default themes, theme editor exports) populate this token or that the codebase provides a typed/ runtime fallback.<br>
- [ ] <a href='https://github.com/apache/superset/pull/37059/files#diff-449931f1bf449596ce5e3ab49828ee91c5fc3532cf191e4dbd44fff4ba779c61R112-R130'><strong>Backward compatibility risk</strong></a><br>The new token must be consistently applied across runtime code paths. If some code expects `brandAppName` to exist (because it's required by the type) but theme merge/serialization doesn't include it, the UI title fallback logic may be incorrect. Ensure either the token is optional in the type OR every theme-default/bootstrap path injects the resolved value (brandAppName → APP_NAME → "Superset").<br>
</td></tr>
</table>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #37059:
URL: https://github.com/apache/superset/pull/37059#discussion_r2682828206
##########
superset/views/base.py:
##########
@@ -567,9 +567,28 @@ def get_spa_template_context(
"""
payload = get_spa_payload(extra_bootstrap_data)
- # Extract theme data for template access
- theme_data = get_theme_bootstrap_data().get("theme", {})
+ # Extract theme data from payload (this is what gets sent to frontend)
+ theme_data = payload.get("common", {}).get("theme", {})
default_theme = theme_data.get("default", {})
+ dark_theme = theme_data.get("dark", {})
+
+ # Apply brandAppName fallback to both default and dark themes
+ # Priority: theme brandAppName > APP_NAME config > "Superset" default
+ app_name_from_config = app.config.get("APP_NAME", "Superset")
+ for theme_config in [default_theme, dark_theme]:
+ if not theme_config:
+ continue
+ theme_tokens = theme_config.get("token", {})
+ if (
+ not theme_tokens.get("brandAppName")
+ or theme_tokens.get("brandAppName") == "Superset"
+ ):
+ # If brandAppName not set or is default, check if APP_NAME customized
+ if app_name_from_config != "Superset":
+ # User has customized APP_NAME, use it as brandAppName
+ theme_tokens["brandAppName"] = app_name_from_config
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Data consistency issue</b></div>
<div id="fix">
The brandAppName fallback modifies theme_tokens in place, which affects the cached theme data shared across requests. This can lead to inconsistent app names being displayed. Use copy.deepcopy on theme_data to isolate changes to this request.
</div>
</div>
<small><i>Code Review Run #4bcc1d</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe closed pull request #37059: fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility
URL: https://github.com/apache/superset/pull/37059
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(theme): migrate APP_NAME to brandAppName theme token with backward compatibility [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #37059:
URL: https://github.com/apache/superset/pull/37059#issuecomment-3786893885
Closing in favor of https://github.com/apache/superset/pull/37370
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org