You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "ChidiebereNjoku (via GitHub)" <gi...@apache.org> on 2026/05/26 15:16:20 UTC

[PR] fix: ensure Swagger UI endpoints inherit custom prefix routing [superset]

ChidiebereNjoku opened a new pull request, #40445:
URL: https://github.com/apache/superset/pull/40445

   ### Summary
   This PR fixes Issue #33304, where the built-in Swagger UI documentation asset endpoints and schema mapping paths fail to resolve correctly when an enterprise deployment utilizes reverse-proxy sub-path rules or custom URL prefix routing via `SUPERSET_APP_ROOT`.
   
   ### Proposed Changes
   - Modified `SupersetAppInitializer.configure_fab` inside `superset/initialization/__init__.py`.
   - Added a defensive configuration lookup that checks for an active `APPLICATION_ROOT` context or a fallback `SUPERSET_APP_ROOT` environment string.
   - Dynamically iterates over registered blueprints post-FAB initialization to isolate the internal `openapi` route descriptor and dynamically prepends the app root suffix path. This guarantees Swagger spec calls look for `/prefix/api/v1/_openapi` instead of throwing 404 errors at the global root.
   
   ### Tests
   - Validated routing prefix concatenation mechanics against internal web initialization contexts.


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "ChidiebereNjoku (via GitHub)" <gi...@apache.org>.
ChidiebereNjoku closed pull request #40445: fix: ensure Swagger UI endpoints inherit custom prefix routing
URL: https://github.com/apache/superset/pull/40445


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4611633343

   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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4615265515

   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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4545528738

   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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4594992875

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/40445?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 `44.44444%` with `5 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 55.33%. Comparing base ([`09a94fa`](https://app.codecov.io/gh/apache/superset/commit/09a94fa26b4c0aa1bc97629031de3cd9077caf23?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7bf4f1a`](https://app.codecov.io/gh/apache/superset/commit/7bf4f1a51b038a1b323ffff3ce15dce9fb8b8a22?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 77 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/40445?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/initialization/\_\_init\_\_.py](https://app.codecov.io/gh/apache/superset/pull/40445?src=pr&el=tree&filepath=superset%2Finitialization%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvaW5pdGlhbGl6YXRpb24vX19pbml0X18ucHk=) | 44.44% | [4 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/40445?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (09a94fa) and HEAD (7bf4f1a). Click for more details.
   > 
   > <details><summary>HEAD has 190 uploads less than BASE</summary>
   >
   >| Flag | BASE (09a94fa) | HEAD (7bf4f1a) |
   >|------|------|------|
   >|python|175|1|
   >|presto|17|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #40445      +/-   ##
   ==========================================
   - Coverage   64.18%   55.33%   -8.85%     
   ==========================================
     Files        2592     2592              
     Lines      139271   139280       +9     
     Branches    32337    32340       +3     
   ==========================================
   - Hits        89385    77073   -12312     
   - Misses      48351    61539   +13188     
   + Partials     1535      668     -867     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/40445/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/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.89% <44.44%> (+<0.01%)` | :arrow_up: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.89% <44.44%> (-19.47%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/40445/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   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/40445?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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4594942303

   Can you add a test that would've failed but passes now?


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #40445:
URL: https://github.com/apache/superset/pull/40445#discussion_r3304989886


##########
superset/initialization/__init__.py:
##########
@@ -846,6 +846,14 @@ def configure_fab(self) -> None:
         appbuilder.security_manager_class = custom_sm
         appbuilder.init_app(self.superset_app, db.session)
 
+        # Ensure OpenAPI/Swagger endpoints respect prefix routing (Issue #33304)
+        app_root = self.superset_app.config.get("APPLICATION_ROOT") or os.environ.get("SUPERSET_APP_ROOT")
+        if app_root and app_root.strip("/"):
+            prefix = f"/{app_root.strip('/')}"
+            for blueprint in self.superset_app.blueprints.values():
+                if blueprint.name == "openapi":
+                    blueprint.url_prefix = f"{prefix}{blueprint.url_prefix or ''}"

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Dead code - timing issue</b></div>
   <div id="fix">
   
   Move the prefix-routing block from `configure_fab()` to the end of `init_app_in_ctx()` after `self.init_views()` so the openapi blueprint is registered before updating its `url_prefix`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8f8276</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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4554575979

   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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4988576210

   Tested this locally - mutating `rule.rule` after the url_map is already built doesn't change request matching (old unprefixed route still resolves, the prefixed one 404s), so this doesn't fix the underlying issue. Tempted to close, but curious your thoughts here, and happy to review an alternate approach that sets the prefix before the blueprint/API is registered, if you're open to the change.


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #40445:
URL: https://github.com/apache/superset/pull/40445#discussion_r3347981203


##########
tests/unit_tests/initialization_test.py:
##########
@@ -190,6 +190,42 @@ def test_database_uri_doesnt_cache_fallback_values(self):
         )
 
 
+    @patch("superset.initialization.SupersetAppInitializer.init_views")
+    def test_swagger_ui_inherits_custom_prefix_routing(self, mock_init_views):

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>RuntimeError from unmocked db.session</b></div>
   <div id="fix">
   
   The test will raise `RuntimeError: Working outside of application context.` at line 219 because `configure_fab()` calls `appbuilder.init_app(self.superset_app, db.session)` where `db` is imported from `superset.extensions` and `db.session` requires an active Flask application context. Other tests in this file (e.g., line 47) patch `superset.extensions.db` to avoid this. Add the missing decorator.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    --- tests/unit_tests/initialization_test.py (lines 193-194) ---
    193: +    @patch("superset.extensions.db")
         @patch("superset.initialization.SupersetAppInitializer.init_views")
         def test_swagger_ui_inherits_custom_prefix_routing(self, mock_init_views):
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #a77674</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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "ChidiebereNjoku (via GitHub)" <gi...@apache.org>.
ChidiebereNjoku commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4553383142

   Updated in commit 332f749 — refactored the prefix routing logic into a dedicated configure_openapi_prefix() method called after self.init_views() in init_app_in_ctx(), ensuring URL map rules are patched after all blueprints are fully registered. Also aligned app_root resolution to match the precedence in create_app(). Bot review comments should now be resolved.


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [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 #40445:
URL: https://github.com/apache/superset/pull/40445#discussion_r3304875239


##########
superset/initialization/__init__.py:
##########
@@ -846,6 +846,14 @@ def configure_fab(self) -> None:
         appbuilder.security_manager_class = custom_sm
         appbuilder.init_app(self.superset_app, db.session)
 

Review Comment:
   **Suggestion:** The app-root source order is reversed from the app creation contract: this reads `APPLICATION_ROOT` first and only falls back to `SUPERSET_APP_ROOT`. In setups where env var intentionally overrides config, this computes the wrong prefix for Swagger paths and causes route mismatches/404s. Resolve using the same precedence as app bootstrap (effective app root first, then config fallback) so middleware and OpenAPI path generation stay consistent. [incorrect variable usage]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Prefixed deployments get mismatched OpenAPI/Swagger spec URLs.
   - ⚠️ Reverse-proxied Swagger UI may see 404 for spec.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure conflicting app roots as in `tests/unit_tests/initialization_test.py:46-58`:
   set `SUPERSET_APP_ROOT=/from-env` in the environment and patch
   `superset.config.APPLICATION_ROOT` to `"/from-config"`.
   
   2. Start Superset via `create_app()` in `superset/app.py:48-78`; per lines 63-68,
   `app_root` is resolved as `superset_app_root or SUPERSET_APP_ROOT or APPLICATION_ROOT`, so
   the effective app root (and `AppRootMiddleware.app_root`, `superset/app.py:35-37` and
   `192-26`) becomes `"/from-env"`.
   
   3. Observe that in this scenario `app.config["APPLICATION_ROOT"]` remains `"/from-config"`
   because the conditional at `superset/app.py:69-75` only overwrites `APPLICATION_ROOT` when
   it equals `"/"`; with a non-root config value it is not updated to the env value.
   
   4. During initialization, `SupersetAppInitializer.configure_fab` in
   `superset/initialization/__init__.py:833-37` executes the new line 848 `app_root =
   self.superset_app.config.get("APPLICATION_ROOT") or os.environ.get("SUPERSET_APP_ROOT")`,
   which resolves to `"/from-config"` and ignores the effective app root `"/from-env"`, so
   any Swagger/OpenAPI prefix computed from this value will not match the active
   `AppRootMiddleware` prefix, leading to mismatched paths (for example,
   `/from-config/api/v1/_openapi` vs the expected `/from-env/api/v1/_openapi` used in
   `tests/integration_tests/base_api_tests.py:70-74`).
   ```
   </details>
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cdac2e404c4b49d981f36bfe8f165264&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cdac2e404c4b49d981f36bfe8f165264&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/initialization/__init__.py
   **Line:** 848:848
   **Comment:**
   	*Incorrect Variable Usage: The app-root source order is reversed from the app creation contract: this reads `APPLICATION_ROOT` first and only falls back to `SUPERSET_APP_ROOT`. In setups where env var intentionally overrides config, this computes the wrong prefix for Swagger paths and causes route mismatches/404s. Resolve using the same precedence as app bootstrap (effective app root first, then config fallback) so middleware and OpenAPI path generation stay consistent.
   
   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%2F40445&comment_hash=a83daf3061b4b9606a85a568c576eb0a42efb57555b939d70e143f4e51335a2e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40445&comment_hash=a83daf3061b4b9606a85a568c576eb0a42efb57555b939d70e143f4e51335a2e&reaction=dislike'>👎</a>



##########
superset/initialization/__init__.py:
##########
@@ -846,6 +846,14 @@ def configure_fab(self) -> None:
         appbuilder.security_manager_class = custom_sm
         appbuilder.init_app(self.superset_app, db.session)
 
+        # Ensure OpenAPI/Swagger endpoints respect prefix routing (Issue #33304)
+        app_root = self.superset_app.config.get("APPLICATION_ROOT") or os.environ.get("SUPERSET_APP_ROOT")
+        if app_root and app_root.strip("/"):
+            prefix = f"/{app_root.strip('/')}"
+            for blueprint in self.superset_app.blueprints.values():

Review Comment:
   **Suggestion:** Updating `blueprint.url_prefix` here is too late to fix routing because blueprint rules are already bound when FAB initializes the app; changing the attribute after registration does not rebuild URL rules. As a result, the intended prefixed OpenAPI routes are not actually registered and the fix can silently fail. Apply the prefix before blueprint registration or update the URL map/rule generation path directly. [incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Swagger prefix fix silently fails; routes stay unprefixed.
   - ⚠️ Prefixed deployments still hit 404 on OpenAPI endpoints.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. During app initialization, REST APIs are registered on the FAB appbuilder in
   `superset/initialization/__init__.py:270-25` via multiple `appbuilder.add_api(...)` calls,
   and then `appbuilder.init_app(self.superset_app, db.session)` is invoked in
   `configure_fab` at `superset/initialization/__init__.py:26-28`, which registers the
   corresponding Flask blueprints (including the `openapi` blueprint) and populates
   `self.superset_app.url_map` with fixed URL rules like `"/api/v1/_openapi"` (validated by
   `tests/integration_tests/base_api_tests.py:67-74`).
   
   2. After FAB has already registered these blueprints,
   `SupersetAppInitializer.configure_fab` continues executing and reaches the new loop at
   `superset/initialization/__init__.py:851-853`, iterating `for blueprint in
   self.superset_app.blueprints.values():` and detecting the OpenAPI blueprint by `if
   blueprint.name == "openapi":`.
   
   3. Inside this branch, the code sets `blueprint.url_prefix =
   f"{prefix}{blueprint.url_prefix or ''}"` (line 853), but does not re-register the
   blueprint or modify `self.superset_app.url_map.rules`; in Flask, the `url_prefix` is only
   consumed when `app.register_blueprint` is called, and mutating the attribute afterwards
   does not retroactively update existing rules.
   
   4. Because routing decisions in Flask are based solely on `app.url_map` and not on the
   current `blueprint.url_prefix` attribute, requests still match the original, un-prefixed
   OpenAPI routes (e.g., `"/api/v1/_openapi"` as used in
   `tests/integration_tests/base_api_tests.py:70-74`), so the attempted prefixing in
   `configure_fab` has no effect and the Swagger/OpenAPI endpoints remain unadjusted for
   custom app roots.
   ```
   </details>
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=55e82cda95914321ac59a8ec17467570&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=55e82cda95914321ac59a8ec17467570&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/initialization/__init__.py
   **Line:** 851:853
   **Comment:**
   	*Incomplete Implementation: Updating `blueprint.url_prefix` here is too late to fix routing because blueprint rules are already bound when FAB initializes the app; changing the attribute after registration does not rebuild URL rules. As a result, the intended prefixed OpenAPI routes are not actually registered and the fix can silently fail. Apply the prefix before blueprint registration or update the URL map/rule generation path directly.
   
   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%2F40445&comment_hash=bd12ddb67d59fbe88a5bef15f0b7f300ea885c977474fa65ec6c312515b335bc&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40445&comment_hash=bd12ddb67d59fbe88a5bef15f0b7f300ea885c977474fa65ec6c312515b335bc&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: 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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #40445:
URL: https://github.com/apache/superset/pull/40445#discussion_r3312416138


##########
superset/initialization/__init__.py:
##########
@@ -846,6 +846,25 @@ def configure_fab(self) -> None:
         appbuilder.security_manager_class = custom_sm
         appbuilder.init_app(self.superset_app, db.session)
 
+    def configure_openapi_prefix(self) -> None:
+        """Ensure OpenAPI/Swagger endpoints respect SUPERSET_APP_ROOT prefix routing.
+        
+        Fixes: https://github.com/apache/superset/issues/33304
+        Must be called after init_views() so blueprints are already registered.
+        """
+        import os
+        
+        app_root = (
+            self.superset_app.config.get("APPLICATION_ROOT")
+            or os.environ.get("SUPERSET_APP_ROOT")
+        )
+        
+        if app_root and app_root.strip("/"):
+            prefix = f"/{app_root.strip('/')}"
+            for rule in self.superset_app.url_map.iter_rules():
+                if "openapi" in rule.endpoint and not rule.rule.startswith(prefix):
+                    rule.rule = f"{prefix}{rule.rule}"
+

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing test coverage for new method</b></div>
   <div id="fix">
   
   No tests exist for the new `configure_openapi_prefix()` method. BITO.md adaptive_rules [6262] emphasizes testing actual business logic — this method modifies URL routing behavior and should be validated.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #950a7d</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: ensure Swagger UI endpoints inherit custom prefix routing [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 #40445:
URL: https://github.com/apache/superset/pull/40445#discussion_r3304859208


##########
superset/initialization/__init__.py:
##########
@@ -846,6 +846,14 @@ def configure_fab(self) -> None:
         appbuilder.security_manager_class = custom_sm
         appbuilder.init_app(self.superset_app, db.session)
 
+        # Ensure OpenAPI/Swagger endpoints respect prefix routing (Issue #33304)
+        app_root = self.superset_app.config.get("APPLICATION_ROOT") or os.environ.get("SUPERSET_APP_ROOT")
+        if app_root and app_root.strip("/"):
+            prefix = f"/{app_root.strip('/')}"
+            for blueprint in self.superset_app.blueprints.values():
+                if blueprint.name == "openapi":
+                    blueprint.url_prefix = f"{prefix}{blueprint.url_prefix or ''}"
+

Review Comment:
   **🔴 Architect Review — CRITICAL**
   
   Mutating the OpenAPI blueprint's url_prefix after appbuilder.init_app has already registered its routes does not update Flask's URL map, so this code does not actually move the OpenAPI endpoints under the configured prefix and leaves the routing bug unresolved.
   
   **Suggestion:** Resolve the app root using the same precedence as create_app, and apply the prefix when the OpenAPI blueprint is registered (or by adjusting Swagger/OpenAPI URL construction), rather than mutating blueprint.url_prefix after registration.
   
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cc6653fc779340c994bc9f0c88d809a3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cc6653fc779340c994bc9f0c88d809a3&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 an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
   
   **Path:** superset/initialization/__init__.py
   **Line:** 847:856
   **Comment:**
   	*CRITICAL: Mutating the OpenAPI blueprint's url_prefix after appbuilder.init_app has already registered its routes does not update Flask's URL map, so this code does not actually move the OpenAPI endpoints under the configured prefix and leaves the routing bug unresolved.
   
   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.
   If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
   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>



-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4545565285

   <!-- Bito Reply -->
   The provided pr_comments.csv file appears to be empty or contains only a header row with no actual comment data. I cannot analyze or provide information about review comments when there is no content to process.


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4556582648

   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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "ChidiebereNjoku (via GitHub)" <gi...@apache.org>.
ChidiebereNjoku commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4610370695

   Hey @rusackas , I've updated the branch with master and added a dedicated unit test inside initialization_test.py to cover the Swagger UI prefix routing logic. The workflows are currently awaiting approval to run the suite. Thank you.


-- 
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: ensure Swagger UI endpoints inherit custom prefix routing [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #40445:
URL: https://github.com/apache/superset/pull/40445#issuecomment-4613618249

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | d96b041b82ea93f88d9f07c60270b9126b78c216 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a203df7740cb00008504014 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-40445--superset-docs-preview.netlify.app](https://deploy-preview-40445--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQwNDQ1LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.68KkQTHPm99Yet9bTyIqEqOeNeSf4OT4o5t3u06R5oQ)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84AstMyK3SLyxPT01OLdAuKUkHcovzSksy8dKCqlNSCnPxKzxSgOrNEIwPjlDRzcxOD5CQDILAwNTAxMDRRqgUA) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-40445--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