bito-code-review[bot] commented on code in PR #37389:
URL: https://github.com/apache/superset/pull/37389#discussion_r2722160531
##########
superset/mcp_service/system/resources/instance_metadata.py:
##########
@@ -88,12 +91,56 @@ def get_instance_metadata_resource() -> str:
logger=logger,
)
- # Use the shared core's resource method
- return instance_info_core.get_resource()
+ # Get base instance info
+ base_result = json.loads(instance_info_core.get_resource())
+
+ # Remove empty popular_content if it has no useful data
+ popular = base_result.get("popular_content", {})
+ if popular and not any(popular.get(k) for k in popular):
+ del base_result["popular_content"]
+
+ # Add available datasets (top 20 by most recent modification)
+ dataset_dao = instance_info_core.dao_classes["datasets"]
+ try:
+ datasets = dataset_dao.find_all()
+ sorted_datasets = sorted(
+ datasets,
+ key=lambda d: getattr(d, "changed_on", None) or "",
+ reverse=True,
+ )[:20]
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>TypeError in dataset sorting</b></div>
<div id="fix">
The dataset sorting logic will raise a TypeError if any dataset has
`changed_on` as None, since it compares datetime objects with strings. This
breaks the metadata retrieval on instances with unmodified datasets.
</div>
</div>
<small><i>Code Review Run #4552ce</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]