bito-code-review[bot] commented on code in PR #42659:
URL: https://github.com/apache/superset/pull/42659#discussion_r3764574444
##########
superset/mcp_service/dashboard/schemas.py:
##########
@@ -305,16 +307,45 @@ def _parse_select_columns(cls, value: Any) -> Any:
parsed = parse_json_or_list(value, "select_columns")
return parsed if parsed else list(DEFAULT_GET_DASHBOARD_INFO_COLUMNS)
+ @model_validator(mode="after")
+ def _require_identifier_or_permalink(self) -> "GetDashboardInfoRequest":
+ if self.identifier is None and self.permalink_key is None:
+ raise ValueError("Provide identifier or permalink_key")
+ return self
+
class GetDashboardLayoutRequest(BaseModel):
- """Request schema for get_dashboard_layout."""
+ """Request a dashboard layout by its identifier or shared permalink.
+
+ Permalink requests resolve the dashboard while preserving shared active-tab
+ and filter state in the response.
+ """
identifier: Annotated[
- int | str,
+ int | str | None,
Field(
- description="Dashboard identifier - can be numeric ID, UUID
string, or slug"
+ default=None,
+ description=(
+ "Dashboard ID, UUID, slug, bare permalink key, or a shared URL
"
+ "containing /superset/dashboard/p/<key>/. Omit when "
+ "permalink_key is provided."
+ ),
),
]
+ permalink_key: str | None = Field(
+ default=None,
+ description=(
+ "Key from a shared dashboard URL such as "
+ "'/superset/dashboard/p/<key>/'. Resolves the dashboard and
includes "
+ "the shared active-tab and filter context in the layout response."
+ ),
+ )
+
+ @model_validator(mode="after")
+ def _require_identifier_or_permalink(self) -> "GetDashboardLayoutRequest":
+ if self.identifier is None and self.permalink_key is None:
+ raise ValueError("Provide identifier or permalink_key")
+ return self
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing schema tests for
GetDashboardLayoutRequest</b></div>
<div id="fix">
New GetDashboardLayoutRequest class lacks any schema unit tests. Add tests
for: (1) model validator rejecting empty requests, (2) valid identifier-only
requests, (3) valid permalink_key-only requests, (4) both fields provided.
</div>
</div>
<small><i>Code Review Run #bbed95</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: [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]