codeant-ai-for-open-source[bot] commented on code in PR #43066:
URL: https://github.com/apache/superset/pull/43066#discussion_r3761671390
##########
superset/mcp_service/chart/tool/get_chart_data.py:
##########
@@ -994,8 +1004,11 @@ async def _query_from_form_data(
error_type="InvalidFormData",
)
- row_limit = (
- request.limit or form_data.get("row_limit") or
current_app.config["ROW_LIMIT"]
+ # row_limit may arrive as a str; coerce it. Keep the trailing fallback so a
+ # falsy 0 still resolves to ROW_LIMIT (as before).
+ row_limit = _coerce_row_limit(
+ request.limit or form_data.get("row_limit") or
current_app.config["ROW_LIMIT"],
+ current_app.config["ROW_LIMIT"],
)
Review Comment:
**Suggestion:** `_coerce_row_limit` accepts negative numeric values, so
cached form data or a request containing a value such as `"-1"` is converted
successfully and passed downstream. `apply_max_row_limit` preserves that
negative value, which can produce an invalid database limit or backend-specific
unlimited-result behavior instead of a bounded query. Reject negative values or
fall back to the configured default during coercion. [type error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ MCP chart queries can fail on negative limits.
- ⚠️ Backend behavior may vary for negative SQL limits.
- ❌ Unsaved chart data retrieval can return an internal error.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d9095397703e49d1aea45e810497155a&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=d9095397703e49d1aea45e810497155a&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/tool/get_chart_data.py
**Line:** 1009:1012
**Comment:**
*Type Error: `_coerce_row_limit` accepts negative numeric values, so
cached form data or a request containing a value such as `"-1"` is converted
successfully and passed downstream. `apply_max_row_limit` preserves that
negative value, which can produce an invalid database limit or backend-specific
unlimited-result behavior instead of a bounded query. Reject negative values or
fall back to the configured default during coercion.
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%2F43066&comment_hash=558bafa9ea2c216e4b5ba5ddf11dc66807d932dff65cc21d603e2f1fc2eb3f49&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43066&comment_hash=558bafa9ea2c216e4b5ba5ddf11dc66807d932dff65cc21d603e2f1fc2eb3f49&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]