codeant-ai-for-open-source[bot] commented on code in PR #41336:
URL: https://github.com/apache/superset/pull/41336#discussion_r3459620472


##########
tests/integration_tests/reports/api_tests.py:
##########
@@ -338,7 +338,8 @@ def test_info_security_report(self):
         assert "can_read" in data["permissions"]
         assert "can_write" in data["permissions"]
         assert "can_subscribe" in data["permissions"]
-        assert len(data["permissions"]) == 3
+        assert "can_execute" in data["permissions"]

Review Comment:
   **Suggestion:** The test now requires a `can_execute` permission in the 
`_info` response, but the new `/execute` endpoint is wired with 
`@permission_name("write")` in the API, so FAB will expose `can_write` (not 
`can_execute`). This makes the test fail and also hides a real contract 
mismatch between expected and actual permission naming. Either change the 
endpoint to use an `execute` permission mapping, or update this assertion to 
match the current `write` permission model. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Integration test `test_info_security_report` fails consistently.
   - ⚠️ `_info` permissions omit standalone execute capability descriptor.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open `tests/integration_tests/reports/api_tests.py` and locate
   `test_info_security_report` at lines 328–342, where it logs in as 
`ADMIN_USERNAME`, calls
   `GET api/v1/report/_info?q=...`, and asserts `"can_execute" in 
data["permissions"]` plus
   `len(data["permissions"]) == 4`.
   
   2. See the backend for this resource in `superset/reports/api.py`: 
`ReportScheduleRestApi`
   defines `include_route_methods` including `"execute"` at lines 86–92 and uses
   `class_permission_name = "ReportSchedule"` and `method_permission_name =
   MODEL_API_RW_METHOD_PERMISSION_MAP` at lines 93–95.
   
   3. Inspect the execute endpoint definition in `superset/reports/api.py` at 
lines 687–696:
   `@expose("/<int:pk>/execute", methods=("POST",))` is decorated with
   `@permission_name("write")`, whereas the subscribe endpoint above (lines 
70–75) uses
   `@permission_name("subscribe")`, which is what produces the 
`"can_subscribe"` permission
   the test already checks.
   
   4. Run `pytest 
tests/integration_tests/reports/api_tests.py::test_info_security_report`:
   the `_info` handler (FAB's `_info` via 
`BaseSupersetModelRestApi.info_headless` in
   `superset/views/base_api.py:43–50`) returns `permissions` derived from the 
registered
   permission names (`read`, `write`, `subscribe`), so the list contains 
`"can_read"`,
   `"can_write"`, and `"can_subscribe"` but not `"can_execute"`, causing the 
assertion at
   line 341 (`assert "can_execute" in data["permissions"]`) and the count 
assertion at line
   342 to fail and revealing the mismatch between the test's expected `execute` 
permission
   and the endpoint's actual `write` permission mapping.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=906c584684e44fda8e57310c282a4866&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=906c584684e44fda8e57310c282a4866&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 a comment left during a code review.
   
   **Path:** tests/integration_tests/reports/api_tests.py
   **Line:** 341:341
   **Comment:**
        *Api Mismatch: The test now requires a `can_execute` permission in the 
`_info` response, but the new `/execute` endpoint is wired with 
`@permission_name("write")` in the API, so FAB will expose `can_write` (not 
`can_execute`). This makes the test fail and also hides a real contract 
mismatch between expected and actual permission naming. Either change the 
endpoint to use an `execute` permission mapping, or update this assertion to 
match the current `write` permission model.
   
   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%2F41336&comment_hash=f21383925b386aed0d830acde0f4ea218723623b6ef6e7bdccadbd0c54a1c8f5&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41336&comment_hash=f21383925b386aed0d830acde0f4ea218723623b6ef6e7bdccadbd0c54a1c8f5&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]

Reply via email to