Skip to content

fix: filter user attached policy accesses on pull#207

Merged
EdouardDem merged 8 commits into
tractr:mainfrom
legendac:fix/filter-user-attached-policy-accesses-on-pull
Apr 13, 2026
Merged

fix: filter user attached policy accesses on pull#207
EdouardDem merged 8 commits into
tractr:mainfrom
legendac:fix/filter-user-attached-policy-accesses-on-pull

Conversation

@legendac
Copy link
Copy Markdown
Contributor

Closes #170

Problem

When a policy is assigned directly to a user (rather than via a role), Directus creates an access record with role = null and user = <uuid>. Two bugs stemmed from this:

  1. Incorrect public policy detection — the public policy is identified by role = null (and user = null). User-attached accesses also have role = null, causing them to be mistakenly matched as the public policy.
  2. Polluted dump on pull — user-attached accesses were included in the policy dump, which is incorrect since they represent user-specific runtime state, not sync-able configuration.

Changes

  • policies/id-mapper-client.ts — tightened the public policy filter to also require user = null, so user-attached accesses (role = null, user = uuid) are no longer mistaken for the public policy.
  • policies/data-client.ts — added roles.user to the fetched fields so user-attached accesses can be identified during pull.
  • policies/data-mapper.ts — overrides mapIdsToSyncIdAndRemoveIgnoredFields to strip any access entries where role = null and user != null before they reach the dump.
  • e2e/push-with-user-policy-assignment.ts — adds a new test asserting that user-attached accesses are absent from the pulled dump.

@legendac
Copy link
Copy Markdown
Contributor Author

Hi @EdouardDem would you be able to review the changes to see if it fixes the issue.

@EdouardDem
Copy link
Copy Markdown
Member

Hi @legendac Thanks for the PR. I approved it. I'm waiting for the tests to pass and i'll publish a new version

@EdouardDem EdouardDem force-pushed the fix/filter-user-attached-policy-accesses-on-pull branch from 5b24ab7 to 630b96f Compare April 13, 2026 21:24
@EdouardDem EdouardDem merged commit 01db43b into tractr:main Apr 13, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Policy without role get's treten as public-policy

2 participants