codeant-ai-for-open-source[bot] commented on code in PR #44416:
URL: https://github.com/apache/superset/pull/44416#discussion_r4044282752
##########
superset/commands/chart/update.py:
##########
@@ -203,22 +208,20 @@ def validate(self) -> None: # noqa: C901
# we don't clobber that message with DatasourceTypeInvalidError.
if datasource_type:
try:
- # Slice.datasource only ever resolves the ``table``
- # relationship (see Slice.datasource in
- # superset/models/slice.py), so setting datasource_type to
- # anything else would "succeed" but leave the chart
- # permanently unable to render -- even for a type-only
- # update that leaves datasource_id untouched. Reject those
- # up front instead of failing later -- either at the lookup
- # below (SavedQuery/Query have no ``.name`` attribute, so
- # accessing it raises an unhandled AttributeError) or
- # silently.
- if datasource_type != DatasourceType.TABLE:
- raise DatasourceTypeInvalidError()
- if datasource_id is not None:
- datasource = get_datasource_by_id(datasource_id,
datasource_type)
- self._properties["datasource_name"] = datasource.name
- security_manager.raise_for_access(datasource=datasource)
+ validate_chart_datasource_type(datasource_type)
+ # A type-only change still selects a different datasource
namespace.
+ effective_id: int | None = (
+ datasource_id
+ if datasource_id is not None
+ else self._model.datasource_id
+ )
Review Comment:
**Suggestion:** Explicit `datasource_id: null` falls back to the stored ID,
so type-only updates with a null ID succeed instead of returning the documented
validation error.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Incorrect
condition logic`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c6165e3ab4224504ab85f47b21b52b89&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=c6165e3ab4224504ab85f47b21b52b89&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/commands/chart/update.py
**Line:** 213:217
**Comment:**
*Incorrect Condition Logic: Explicit `datasource_id: null` falls back
to the stored ID, so type-only updates with a null ID succeed instead of
returning the documented validation error.
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%2F44416&comment_hash=1f86d4ef23373fb636156d2917cd63e56c51a7e22edc6fff667571f825b9d374&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44416&comment_hash=1f86d4ef23373fb636156d2917cd63e56c51a7e22edc6fff667571f825b9d374&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]