aminghadersohi commented on code in PR #37216:
URL: https://github.com/apache/superset/pull/37216#discussion_r2706498165
##########
superset/mcp_service/auth.py:
##########
@@ -212,6 +220,15 @@ async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
with _get_app_context_manager():
user = _setup_user_context()
+ # If no Flask context, execute without user context
+ # (middleware will provide context later for tools)
+ if user is None:
Review Comment:
Good point about the comment being misleading. The user is None case happens
when there's no
Flask context - this occurs during FastMCP internal operations (tool
discovery, prompt listing)
that run outside of any HTTP request. In those cases, there's no middleware
because there's no
request at all.
The comment "middleware will provide context later" is incorrect - I'll
update it to clarify:
# No Flask context - this is a FastMCP internal operation
# (e.g., tool discovery, prompt listing) that doesn't require auth
The duplication between async_wrapper and sync_wrapper is unfortunately
unavoidable for decorators that support both sync and async functions in
Python.
As always im 100% open to any suggestions
--
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]