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