codeant-ai-for-open-source[bot] commented on code in PR #43500:
URL: https://github.com/apache/superset/pull/43500#discussion_r3849646226
##########
superset/commands/chart/update.py:
##########
@@ -223,6 +225,17 @@ def validate(self) -> None: # noqa: C901
# Validate/Populate datasource
if datasource_id is not None:
try:
+ # Slice.datasource only ever resolves the ``table``
+ # relationship (see Slice.datasource in
+ # superset/models/slice.py), so repointing a chart at any
+ # other datasource_type would "succeed" but leave the chart
+ # permanently unable to render. Reject those up front
+ # instead of failing later -- either at this lookup
+ # (SavedQuery/Query have no ``.name`` attribute, so
+ # accessing it below raises an unhandled AttributeError) or
+ # silently.
+ if datasource_type != DatasourceType.TABLE:
+ raise DatasourceTypeInvalidError()
Review Comment:
**Suggestion:** The new guard raises `DatasourceTypeInvalidError` inside a
`try` block that catches `ValidationError`, so it is appended rather than
propagated. When `datasource_id` is supplied without `datasource_type`, the
existing `DatasourceTypeUpdateRequiredValidationError` is already appended,
then this guard appends the invalid-type error for the empty string.
`normalized_messages()` updates the same `datasource_type` key with the later
error, changing the established response from “Datasource type is required when
datasource_id is given” to the incorrect “Datasource type is invalid.” Only
perform this check when a non-empty datasource type was supplied, or preserve
the required-field error. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Chart PUT requests omitting datasource type return the wrong validation
message.
- ⚠️ Clients lose the required-field guidance for datasource updates.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=74294e23a9b34d18ab56e39074c67f88&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=74294e23a9b34d18ab56e39074c67f88&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:** 237:238
**Comment:**
*Api Mismatch: The new guard raises `DatasourceTypeInvalidError` inside
a `try` block that catches `ValidationError`, so it is appended rather than
propagated. When `datasource_id` is supplied without `datasource_type`, the
existing `DatasourceTypeUpdateRequiredValidationError` is already appended,
then this guard appends the invalid-type error for the empty string.
`normalized_messages()` updates the same `datasource_type` key with the later
error, changing the established response from “Datasource type is required when
datasource_id is given” to the incorrect “Datasource type is invalid.” Only
perform this check when a non-empty datasource type was supplied, or preserve
the required-field 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%2F43500&comment_hash=7796b213412594992a8f4d3b1054f1d0868c685508d7e49a677b2a046ff557b6&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43500&comment_hash=7796b213412594992a8f4d3b1054f1d0868c685508d7e49a677b2a046ff557b6&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]