codeant-ai-for-open-source[bot] commented on code in PR #38033:
URL: https://github.com/apache/superset/pull/38033#discussion_r3564748669


##########
superset/app.py:
##########
@@ -81,6 +81,12 @@ def create_app(
             # value of app_root so things work out of the box
             if not app.config["STATIC_ASSETS_PREFIX"]:
                 app.config["STATIC_ASSETS_PREFIX"] = app_root
+            # Prefix APP_ICON path with subdirectory root for subdirectory 
deployments
+            if (
+                app.config.get("APP_ICON", "").startswith("/static/")
+                and app_root != "/"
+            ):
+                app.config["APP_ICON"] = f"{app_root}{app.config['APP_ICON']}"

Review Comment:
   **Suggestion:** This rewrite hardcodes `APP_ICON` to `app_root + 
/static/...`, which ignores `STATIC_ASSETS_PREFIX` when operators use a CDN or 
a dedicated static prefix. In subdirectory deployments with a non-empty static 
prefix, the login/logo URL will point to the wrong host/path and break icon 
loading. Build the rewritten icon URL from `STATIC_ASSETS_PREFIX` (or only 
rewrite when that prefix is empty) instead of always using `app_root`. [logic 
error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Navbar/logo image broken under CDN static prefix deployment.
   - ⚠️ MCP server logo_url inconsistent with CDN asset host.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure Superset to use a CDN static prefix by setting 
STATIC_ASSETS_PREFIX in
   superset_config.py; this value is loaded into app.config via create_app at
   superset/app.py:60-63.
   
   2. Deploy Superset under a subdirectory by setting SUPERSET_APP_ROOT (or 
passing
   superset_app_root) so that app_root is computed as a non-root path (for 
example
   "/superset") in superset/app.py:65-78.
   
   3. On app startup, create_app in superset/app.py:52-92 runs; because 
app_root != "/", the
   block at lines 79-91 executes. STATIC_ASSETS_PREFIX remains the CDN host 
(the condition at
   line 82-83 is false), but the APP_ICON rewrite at lines 85-89 sets 
app.config["APP_ICON"]
   = f"{app_root}{app.config['APP_ICON']}", producing a subdirectory-relative 
path like
   "/superset/static/assets/images/superset-logo-horiz.png" that ignores the CDN
   STATIC_ASSETS_PREFIX.
   
   4. The theme token brandLogoUrl is derived from APP_ICON in 
superset/config.py:1060-1074,
   and sent to the frontend via bootstrap_data (views/base.py:570-37). Under a 
deployment
   where static assets are served only from the CDN STATIC_ASSETS_PREFIX, the 
browser
   requests "/superset/static/..." from the app host instead of the CDN, 
causing the logo
   image to fail to load on the login/navbar UI.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3559f9031c234420827bb2d4b825cb8f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3559f9031c234420827bb2d4b825cb8f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/app.py
   **Line:** 85:89
   **Comment:**
        *Logic Error: This rewrite hardcodes `APP_ICON` to `app_root + 
/static/...`, which ignores `STATIC_ASSETS_PREFIX` when operators use a CDN or 
a dedicated static prefix. In subdirectory deployments with a non-empty static 
prefix, the login/logo URL will point to the wrong host/path and break icon 
loading. Build the rewritten icon URL from `STATIC_ASSETS_PREFIX` (or only 
rewrite when that prefix is empty) instead of always using `app_root`.
   
   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.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38033&comment_hash=80f27712de7b006bf5b57c844ddab6947896a4e4a85117ba2a2ac0b76cf392d1&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38033&comment_hash=80f27712de7b006bf5b57c844ddab6947896a4e4a85117ba2a2ac0b76cf392d1&reaction=dislike'>👎</a>



-- 
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]

Reply via email to