You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/04/27 23:49:03 UTC
Re: [PR] feat(mcp): restore self-lookup via created_by_me flag [superset]
eschutho commented on code in PR #39638:
URL: https://github.com/apache/superset/pull/39638#discussion_r3150776941
##########
superset/mcp_service/common/cache_schemas.py:
##########
@@ -83,6 +85,69 @@ class FormDataCacheControl(CacheControlMixin):
)
+class CreatedByMeMixin(BaseModel):
+ """Mixin that adds a created_by_me filter flag to list request schemas.
+
+ Provides a clean caller-facing alternative to exposing foreign key IDs.
+ The server translates the flag into the appropriate FK filter and injects
+ the current user's ID automatically.
+ """
+
+ created_by_me: Annotated[
+ bool,
+ Field(
+ default=False,
+ description=(
+ "When true, return only items created by the current user. "
+ "Can be combined with 'filters' but not with 'search'."
+ ),
+ ),
+ ]
+
+ @model_validator(mode="after")
+ def _validate_created_by_me_with_search(self) -> Any:
+ if getattr(self, "search", None) and self.created_by_me:
+ raise ValueError(
+ "'created_by_me' cannot be combined with 'search'. "
+ "Use 'created_by_me' alone or with 'filters'."
+ )
+ return self
+
+
+class OwnedByMeMixin(BaseModel):
+ """Mixin that adds an owned_by_me filter flag to list request schemas.
+
+ Provides a clean caller-facing alternative to exposing M2M owner IDs.
+ The server translates the flag into the appropriate owner filter and injects
+ the current user's ID automatically.
+
+ When combined with created_by_me, returns items where the current user is
+ either the creator OR an owner (union, not intersection).
Review Comment:
We can also make this an AND instead of an OR, or we could throw a schema error if both created by me and owned by me are passed. It seemed likely that the user is going to want both if they ask for both, which creates a new filter type. Most filters are OR.
--
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