codeant-ai-for-open-source[bot] commented on code in PR #44681:
URL: https://github.com/apache/superset/pull/44681#discussion_r4112661960
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -128,7 +129,16 @@ class ChartInfo(BaseModel):
"fall back to viz_type when this field is null."
),
)
- datasource_name: str | None = Field(None, description="Datasource name")
+ datasource_id: int | None = Field(
+ None, description="ID of the dataset (or semantic view) the chart
queries"
+ )
Review Comment:
**Suggestion:** The new `datasource_id` field is omitted from
`DEFAULT_GET_CHART_INFO_COLUMNS`, so default chart responses still provide the
name without its identifier.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Often` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=31b16f12005942d4861e1c5af8e804a3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=31b16f12005942d4861e1c5af8e804a3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/schemas.py
**Line:** 132:134
**Comment:**
*Api Mismatch: The new `datasource_id` field is omitted from
`DEFAULT_GET_CHART_INFO_COLUMNS`, so default chart responses still provide the
name without its identifier.
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.
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>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=113d1d2d26a057c55db9fe4a901197ca97363d7df55fc852acbd5b2945ac21d3&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=113d1d2d26a057c55db9fe4a901197ca97363d7df55fc852acbd5b2945ac21d3&reaction=dislike'>๐</a>
##########
superset/mcp_service/dashboard/schemas.py:
##########
@@ -1795,7 +1808,10 @@ def serialize_chart_summary(
id=chart_id,
slice_name=getattr(chart, "slice_name", None),
viz_type=getattr(chart, "viz_type", None),
- datasource_name=getattr(chart, "datasource_name", None)
+ datasource_id=resolve_chart_datasource_id(chart)
+ if include_data_model_metadata
+ else None,
+ datasource_name=resolve_chart_datasource_name(chart)
if include_data_model_metadata
else None,
Review Comment:
**Suggestion:** `datasource_name_text()` resolves only table and
semantic-view relationships, so query or saved-query charts lose their valid
stored datasource name and return `null`.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b8a566515b5e4a2ea2eb451d18e20aaa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b8a566515b5e4a2ea2eb451d18e20aaa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/dashboard/schemas.py
**Line:** 1814:1816
**Comment:**
*Logic Error: `datasource_name_text()` resolves only table and
semantic-view relationships, so query or saved-query charts lose their valid
stored datasource name and return `null`.
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.
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>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=0147e47eaebb2a0084d1f2b3c8efc2d156a493a4422d9c97f412176abaa889d5&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=0147e47eaebb2a0084d1f2b3c8efc2d156a493a4422d9c97f412176abaa889d5&reaction=dislike'>๐</a>
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -549,7 +559,41 @@ def extract_filters_from_form_data(
)
-def serialize_chart_object(chart: ChartLike | None) -> ChartInfo | None:
+def resolve_chart_datasource_id(chart: Any) -> int | None:
+ """Return the ID of the datasource a chart is joined to."""
+ datasource_id = getattr(chart, "datasource_id", None)
+ if isinstance(datasource_id, int) and not isinstance(datasource_id, bool):
+ return datasource_id
+ return None
+
+
+def resolve_chart_datasource_name(chart: Any) -> str | None:
+ """Return the chart's datasource name, read from the live datasource.
+
+ ``Slice.datasource_name`` is a stored, denormalized column that is not
+ refreshed when a dataset is renamed or a chart is re-pointed, so it can
+ name a table the chart no longer queries. ``Slice.datasource_name_text``
+ resolves the name through the type-guarded ``table`` / ``semantic_view``
+ relationships instead, and yields ``None`` when the datasource no longer
+ exists. Objects without that resolver (row tuples, lightweight stand-ins)
+ fall back to the stored value.
+ """
+ resolver = getattr(chart, "datasource_name_text", None)
+ if callable(resolver):
+ live_name = resolver()
+ if live_name is None or isinstance(live_name, str):
+ return live_name
Review Comment:
**Suggestion:** `datasource_name_text()` returns `None` for query or
saved-query charts, so valid stored datasource names disappear instead of using
the documented fallback.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3ee1cfd8b2ad42d59e97631c615dfdfe&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3ee1cfd8b2ad42d59e97631c615dfdfe&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/schemas.py
**Line:** 581:585
**Comment:**
*Logic Error: `datasource_name_text()` returns `None` for query or
saved-query charts, so valid stored datasource names disappear instead of using
the documented fallback.
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.
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>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=3a5ec1c38f759b2c283b2fc90656ca736d305ec960abba833d75798e06bddf80&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44681&comment_hash=3a5ec1c38f759b2c283b2fc90656ca736d305ec960abba833d75798e06bddf80&reaction=dislike'>๐</a>
--
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]