test(api): regression for remove_granular_acl on multi-version scripts (WIN-2004)#9824
Conversation
The `script` table is keyed on `(workspace_id, hash)`, so multiple rows can share the same `(workspace_id, path)` across versions. `add_granular_acl` writes `extra_perms` to every row matching the path, so when >=2 versions carry the permission key, the CTE in `remove_granular_acl` returned more than one row and PostgreSQL rejected the scalar subquery in RETURNING with "more than one row returned by a subquery used as an expression". The production fix (LIMIT 1 on the RETURNING subquery) shipped in #9388 but without a regression test. This adds an integration test that creates a two-version script, grants then revokes a granular ACL, and asserts the revoke succeeds (it 500'd before the fix, verified by reverting LIMIT 1). Fixes WIN-2004 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @rubenfiszel's task in 3m 48s —— View job Code reviewGood to merge. This is a clean, correct regression test for Correctness checks (all pass):
Findings: none (no P0/P1/P2). Optional note (non-blocking): there is already an ACL-focused integration test at Test coverageThis PR is test coverage — a backend integration test for a previously-fixed-but-untested DB bug. It exercises the full HTTP path (create → add ACL → remove ACL → assert key gone) and asserts both the success status and the post-state. No further automated tests needed. No manual verification required beyond CI running the new test. |
|
I've examined the diff, the referenced production code ( Pi ReviewGood to merge. This is a clean regression test that adds the missing coverage mentioned in the PR description. The test properly sets up the multi-version script scenario, verifies the two-version invariant, grants/revokes a granular ACL, and asserts the permission key is gone from every version. What I checked
Test coverageBackend: this is a new integration test covering a previously untested edge case (multi-version script + granular ACL removal). The PR description confirms the test was validated both with and without the fix — it passes with No manual verification required — this is a backend-only integration test with no UI surface. |
Deploying windmill with
|
| Latest commit: |
03c3f08
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0ff78ddc.windmill.pages.dev |
| Branch Preview URL: | https://ruben-win-2004-fix-remove-gr.windmill.pages.dev |
Codex ReviewGood to merge. No confirmed issues found. Checked the backend test-only diff for bugs, security concerns, and AGENTS.md compliance. Test coverageThis PR adds a targeted backend integration regression test for removing granular ACLs from multi-version scripts, which matches the changed surface. No in-app manual verification is needed because the diff only adds test coverage. Manual verification still useful before merge: run the targeted backend test for |
Summary
remove_granular_aclused a CTE whose result was read as a scalar subquery inRETURNING (SELECT old_write FROM old)::bool. Thescripttable is keyed on(workspace_id, hash), so several rows can share the same(workspace_id, path)across versions.add_granular_aclwritesextra_permsto every row matching the path, so once a script has ≥2 versions carrying
the permission key, that CTE returned more than one row and PostgreSQL rejected
the request with:
The production fix —
LIMIT 1on theRETURNINGscalar subquery — alreadyshipped in #9388, but without a regression test. This PR adds that missing
test so the bug can't silently come back.
What this PR contains
backend/tests/granular_acl_multi_version.rs— integration test that:(workspace_id, path)),No production code changes —
granular_acls.rsis unchanged frommain.Validation
LIMIT 1locally): test fails withexactly
more than one row returned by a subquery used as an expression(HTTP 400), confirming it reproduces the reported bug.
sqlx::query_scalar()function, so no.sqlxoffline-cache update is required.
Fixes WIN-2004
🤖 Generated with Claude Code
Summary by cubic
Adds a regression test for remove_granular_acl on scripts with multiple versions to prevent the multi-row scalar subquery error from returning. The test creates two versions at the same path, grants then revokes a granular ACL, and asserts 200 plus removal from all versions, covering WIN-2004.
Written for commit 03c3f08. Summary will update on new commits.