codeant-ai-for-open-source[bot] commented on code in PR #40497:
URL: https://github.com/apache/superset/pull/40497#discussion_r3319466686
##########
superset/views/api.py:
##########
@@ -89,6 +90,14 @@ def query_form_data(self) -> FlaskResponse:
if slice_id := request.args.get("slice_id"):
slc = db.session.query(Slice).filter_by(id=slice_id).one_or_none()
if slc:
+ # Normalise unauthorised access to the same 404 the modern
+ # ChartRestApi.get returns, so callers cannot distinguish
+ # "chart does not exist" from "chart exists but is denied"
+ # by status code.
+ try:
+ security_manager.raise_for_access(chart=slc)
+ except SupersetSecurityException:
+ return self.json_response({}, 404)
Review Comment:
**🟠Architect Review — HIGH**
The legacy /api/v1/form_data endpoint still returns HTTP 200 with an empty
{} body when the requested slice_id does not exist, but returns HTTP 404 when
the slice exists and access is denied, so callers can distinguish "missing" vs
"forbidden" purely by status code despite the comment aiming to avoid that
oracle.
**Suggestion:** For requests that include slice_id, return the same 404
response (status and shape) used by ChartRestApi.get when the chart is missing
(slc is None) or access is denied, and add an integration test covering a
non-existent slice_id to lock this behavior.
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c2e86bc7e2214b51a614a97d6e238a8e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c2e86bc7e2214b51a614a97d6e238a8e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is an **Architect / Logical Review** comment left during a code review.
These reviews are first-class, important findings — not optional suggestions.
Do NOT dismiss this as a 'big architectural change' just because the title says
architect review; most of these can be resolved with a small, localized fix
once the intent is understood.
**Path:** superset/views/api.py
**Line:** 90:100
**Comment:**
*HIGH: The legacy /api/v1/form_data endpoint still returns HTTP 200
with an empty {} body when the requested slice_id does not exist, but returns
HTTP 404 when the slice exists and access is denied, so callers can distinguish
"missing" vs "forbidden" purely by status code despite the comment aiming to
avoid that oracle.
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.
If a suggested approach is provided above, use it as the authoritative
instruction. If no explicit code suggestion is given, you MUST still draft and
apply your own minimal, localized fix — do not punt back with 'no suggestion
provided, review manually'. Keep the change as small as possible: add a guard
clause, gate on a loading state, reorder an await, wrap in a conditional, etc.
Do not refactor surrounding code or expand scope beyond the finding.
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>
--
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]