test(rls): make matching-GUC count consistent with owner count (PMS-430) #317
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-430-rls-isolation-guc-count-internal-consistency"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The rls_isolation regression broke on main from a semantic merge conflict between two independently-correct branch edits to the same assertion. PMS-414 (#310) changed the assertion to compare the matching-GUC read against tenant_a_companies, the owner-visible count(*) WHERE tenant_id = $1, which includes the internal own-company that PMS-413 migration 062 backfills for the default tenant (= 2). PMS-413 separately added WHERE company_type <> 'internal' to the GUC count (= 1), which was consistent only against the old hard-coded 1. Merged together the two counts use different filters, so the assertion compares 1 against 2 and fails ("tenant-A GUC returned 2 rows instead of the expected 1").
The internal own-company is a legitimate tenant-A row that RLS must expose under the matching GUC, so the GUC count must include it to match the owner count. Drop the <> 'internal' filter from the GUC count so both sides count the same set; the test still proves fail-closed reads (zero rows with no GUC) and that the matching GUC exposes exactly tenant A's rows.
#PMS-430
Pull request closed