directus-sync icon indicating copy to clipboard operation
directus-sync copied to clipboard

Policy without role get's treten as public-policy

Open Dominic-Marcelino opened this issue 7 months ago • 1 comments

Describe the bug The extension uses a custom flag _sync_default_public_policy for the default public policy. However, after a custom policy is added which isn't related to a role (but assigned to a single user), the extension tries to save it as a second default public policy on a pull, which creates the error below:

insert into `directus_sync_id_map` (`local_id`, `sync_id`, `table`) values ('25c4d514-026a-400d-beeb-398b078b8ea6', '_sync_default_public_policy', 'policies') - Duplicate entry 'policies-_sync_default_public_policy' for key 'directus_sync_id_map_table_sync_id_unique'

After adding the policy manually to the directus_sync_id_map table (keeping the id), everything works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Create a policy which isn't assigned to a role
  2. Run directus-sync pull
  3. See error

Expected behavior Recognize that it's a user-related policy.

Versions (please complete the following information):

  • Directus-Sync version: 3.0.3
  • Directus version: 11.6.1
  • Database: MySql
  • Directus environment: Docker

Dominic-Marcelino avatar Jun 03 '25 12:06 Dominic-Marcelino

@Dominic-Marcelino Thanks for reporting the bug. I will work on this.

EdouardDem avatar Sep 25 '25 02:09 EdouardDem