codeant-ai-for-open-source[bot] commented on code in PR #43687:
URL: https://github.com/apache/superset/pull/43687#discussion_r3887122328
##########
superset/commands/chart/create.py:
##########
@@ -47,7 +48,12 @@ def __init__(self, data: dict[str, Any]):
self._properties = data.copy()
if params_str := self._properties.get("params"):
- params = json.loads(params_str)
+ try:
+ params = json.loads(params_str)
+ except json.JSONDecodeError as ex:
+ raise ChartInvalidError(
+ exceptions=[ChartParamsInvalidJSONValidationError()]
+ ) from ex
Review Comment:
**Suggestion:** This conversion to `ChartInvalidError` does not fix the
public POST behavior: `ChartPostSchema` validates `params` with `validate_json`
before `CreateChartCommand` is constructed, so malformed HTTP input is rejected
by the schema and returned as a 400. The new 422 path is therefore unreachable
for the endpoint described by this change. Move the JSON validation to the
command path or update the API's schema-validation handling if malformed
`params` is required to return 422. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Malformed chart POST requests remain HTTP 400.
- ⚠️ `ChartInvalidError` 422 handling is unreachable publicly.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9e3ea201fc104abba7e4d9b60e7a5ca2&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=9e3ea201fc104abba7e4d9b60e7a5ca2&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/create.py
**Line:** 53:56
**Comment:**
*Api Mismatch: This conversion to `ChartInvalidError` does not fix the
public POST behavior: `ChartPostSchema` validates `params` with `validate_json`
before `CreateChartCommand` is constructed, so malformed HTTP input is rejected
by the schema and returned as a 400. The new 422 path is therefore unreachable
for the endpoint described by this change. Move the JSON validation to the
command path or update the API's schema-validation handling if malformed
`params` is required to return 422.
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%2F43687&comment_hash=9087ee71d8cdfef5e952dbf4f8cdb19aae46c98f1b1bf3744058687c92e5f618&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43687&comment_hash=9087ee71d8cdfef5e952dbf4f8cdb19aae46c98f1b1bf3744058687c92e5f618&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]