directus-sync
directus-sync copied to clipboard
Policy without role get's treten as public-policy
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:
- Create a policy which isn't assigned to a role
- Run
directus-sync pull - 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 Thanks for reporting the bug. I will work on this.