codeant-ai-for-open-source[bot] commented on code in PR #39947:
URL: https://github.com/apache/superset/pull/39947#discussion_r3200985609
##########
tests/integration_tests/datasource/api_tests.py:
##########
@@ -212,10 +212,8 @@ def test_combined_list_invalid_order_column(
run_mock,
can_access_mock,
):
- security_manager.add_permission_view_menu("can_combined_list",
"Datasource")
- perm = security_manager.find_permission_view_menu(
- "can_combined_list", "Datasource"
- )
+ security_manager.add_permission_view_menu("can_read", "Datasource")
+ perm = security_manager.find_permission_view_menu("can_read",
"Datasource")
Review Comment:
**Suggestion:** This test was migrated to grant `can_read` on `Datasource`,
but other `combined_list` tests in the same file still grant
`can_combined_list`. Because the endpoint permission is now `can_read`, those
tests can fail with 403 when run in isolation (or become order-dependent if
this test runs first and mutates role permissions). Update the remaining
`combined_list` tests to grant `can_read` (or move permission setup to a shared
fixture) so each test is self-contained. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ `test_combined_list_semantic_layers_off` fails when run in isolation.
- ⚠️ Test suite becomes order-dependent for combined_list tests.
- ⚠️ Flaky CI possible if test ordering or selection changes.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Note the new permission mapping for the endpoint in
`superset/datasource/api.py`:
`DatasourceRestApi` defines `method_permission_name = {"combined_list":
"read"}` at lines
40–48 and the `combined_list` view at lines 11–20 and 42–48 (second snippet,
lines 11–20
and 42–48) is decorated with `@protect()`, which enforces `can_read` on
class permission
`Datasource`.
2. In `tests/integration_tests/datasource/api_tests.py`, inspect
`test_combined_list_invalid_order_column` at lines 208–223: it creates and
grants
`("can_read", "Datasource")` to the Admin role via
`security_manager.add_permission_view_menu("can_read", "Datasource")` and
`security_manager.add_permission_role(admin_role, perm)` (lines 215–218), so
this test
aligns with the new mapping.
3. In the same file, inspect `test_combined_list_semantic_layers_off` at
lines 231–255: it
still creates and grants `("can_combined_list", "Datasource")` (lines
238–243) and never
creates or assigns `("can_read", "Datasource")`. When this test is run in
isolation, the
Admin role lacks `can_read` on `Datasource`, so the `@protect()` check for
`combined_list`
fails with 403 before the body executes, even though
`security_manager.can_access` is
patched to return True (lines 231–244).
4. Run this test alone, e.g. `pytest
tests/integration_tests/datasource/api_tests.py::TestDatasourceApi::test_combined_list_semantic_layers_off`.
The request to `GET
/api/v1/datasource/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:25)`
at lines 248–251 returns HTTP 403 instead of the expected 200 at line 253,
causing the
test to fail; if `test_combined_list_invalid_order_column` runs first in the
same process
it seeds `can_read` and masks the bug, making the behavior order-dependent.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Fintegration_tests%2Fdatasource%2Fapi_tests.py%0A%2A%2ALine%3A%2A%2A%20215%3A216%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20This%20test%20was%20migrated%20to%20grant%20%60can_read%60%20on%20%60Datasource%60%2C%20but%20other%20%60combined_list%60%20tests%20in%20the%20same%20file%20still%20grant%20%60can_combined_list%60.%20Because%20the%20endpoint%20permission%20is%20now%20%60can_read%60%2C%20those%20tests%20can%20fail%20with%20403%20when%20run%20in%20isolation%20%28or%20become%20order-dependent%20if%20this%20test%20runs%20first%20and%20mutates%20role%20permissions%29.%20Update%20the%20remaining%20%60combined_list%60%20tests%20to%20grant%20%60can_read%60%20%28or%20move%20permission%20setup%20to%20a%20shared%20fixture%29%20so%20each%20test%20is%20self-contained.%0A%0AValidate%20the%20correctness%20of%20the%20flag
ged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Fintegration_tests%2Fdatasource%2Fapi_tests.py%0A%2A%2ALine%3A%2A%2A%20215%3A216%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20This%20test%20was%20migrated%20to%20grant%20%60can_read%60%20on%20%60Datasource%60%2C%20but%20other%20%60combined_list%60%20tests%20in%20the%20same%20file%20still%20grant%20%60can_combined_list%60.
%20Because%20the%20endpoint%20permission%20is%20now%20%60can_read%60%2C%20those%20tests%20can%20fail%20with%20403%20when%20run%20in%20isolation%20%28or%20become%20order-dependent%20if%20this%20test%20runs%20first%20and%20mutates%20role%20permissions%29.%20Update%20the%20remaining%20%60combined_list%60%20tests%20to%20grant%20%60can_read%60%20%28or%20move%20permission%20setup%20to%20a%20shared%20fixture%29%20so%20each%20test%20is%20self-contained.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(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/datasource/api_tests.py
**Line:** 215:216
**Comment:**
*Logic Error: This test was migrated to grant `can_read` on
`Datasource`, but other `combined_list` tests in the same file still grant
`can_combined_list`. Because the endpoint permission is now `can_read`, those
tests can fail with 403 when run in isolation (or become order-dependent if
this test runs first and mutates role permissions). Update the remaining
`combined_list` tests to grant `can_read` (or move permission setup to a shared
fixture) so each test is self-contained.
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%2F39947&comment_hash=478f8870073ccc0d239a5bc1668e070dfd25eae554cc910a62e7a112c8a244bb&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39947&comment_hash=478f8870073ccc0d239a5bc1668e070dfd25eae554cc910a62e7a112c8a244bb&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]