Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton Push #106

Open
NilsBaumgartner1994 opened this issue Sep 23, 2024 · 6 comments
Open

Singleton Push #106

NilsBaumgartner1994 opened this issue Sep 23, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@NilsBaumgartner1994
Copy link

[00:02:40.194] INFO (29613): ---- Push schema ----
[00:02:41.157] INFO (29613): [snapshot] No changes to apply
[00:02:41.165] INFO (29613): ---- Clean up collections ----
[00:02:41.309] INFO (29613): [settings] Deleted 0 dangling items
[00:02:42.014] INFO (29613): [folders] Deleted 0 dangling items
[00:02:42.075] INFO (29613): [translations] Deleted 0 dangling items
[00:02:42.914] INFO (29613): [flows] Deleted 0 dangling items
[00:02:43.479] INFO (29613): [operations] Deleted 0 dangling items
[00:02:43.763] INFO (29613): [roles] Deleted 0 dangling items
[00:02:44.074] INFO (29613): [policies] Deleted 0 dangling items
[00:02:46.820] INFO (29613): [permissions] Deleted 0 dangling items
[00:02:46.914] INFO (29613): [dashboards] Deleted 0 dangling items
[00:02:47.011] INFO (29613): [panels] Deleted 0 dangling items
[00:02:47.072] INFO (29613): [presets] Deleted 0 dangling items
[00:02:47.072] INFO (29613): ---- Push: iteration 1 ----
[00:02:47.283] ERROR (29613): Local id already exists
    err: {
      "type": "ConflictError",
      "message": "Local id already exists",
      "stack":
          ConflictError: Local id already exists
              at SettingsIdMapperClient.<anonymous> (/Users/nilsbaumgartner/Documents/GitHub/rocket-meals/backend/sync/node_modules/directus-sync/dist/lib/services/extension-client.js:48:55)
              at Generator.next (<anonymous>)
              at fulfilled (/Users/nilsbaumgartner/Documents/GitHub/rocket-meals/backend/sync/node_modules/directus-sync/dist/lib/services/extension-client.js:14:58)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      "status": 409,
      "statusCode": 409,
      "expose": true
    }

as we tried to push, an existing singleton made problems.
We had a workaround by deleting all directus-sync map ids, then push again.

@muhdnajmuddin
Copy link

muhdnajmuddin commented Oct 17, 2024

image

Hi, I ran into the same issue, can you help me to point out where are the directus-sync map ids located yea?

@NilsBaumgartner1994
Copy link
Author

image

Hi, I ran into the same issue, can you help me to point out where are the directus-sync map ids located yea?

Sorry I still haven’t found a workaround

@EdouardDem
Copy link
Member

Hi. How did. get this error ? Is it after a migration ? On which collection ?

It seems that the sync Id has been updated between 2 sync.

You don't have to delete all sync ids, you can use the following command :
npx directus-sync helpers untrack --collection policies --id xxxx-xxxx-xxx

If you prefer you can browse the sync ids map from Directus.

First, you have to activate the model :

image

Then you can select on or more sync id map that cause the issue.
In your case it seems to be the policies table :

image

@EdouardDem EdouardDem added the bug Something isn't working label Oct 24, 2024
@sethjgore
Copy link

I had the same issue and I believe the bug comes from:

sync ids require the local ids to be unique however,

the _sync_default_admin_role and _sync_default_admin_policy both are set with the same local id. You can see the screenshot above, the same errors apply.

I haven't read through the code to see what's happening, but I assume it's either an assignment error or they both come from the same location.

@sethjgore
Copy link

sethjgore commented Nov 1, 2024

I have identified the issue — both id-mapper-client.ts in roles and policy folders have methods that return the same ID due to the nature of how Directus sets up admin role and policy. They both are THE SAME ID as shown in screenshots between Settings > User Role and Settings > Policies

Screenshot 2024-11-01 at 11 49 45 AM Screenshot 2024-11-01 at 11 49 37 AM

So, the methods that return the policy id and the role id return the same ID, which causes the error when ensuring that local IDs are unique. I would think that you would need to update wherever it enforces that to allow same local IDs if it is from a different table. That's my best guess. Hope this helps!

@EdouardDem
Copy link
Member

EdouardDem commented Nov 8, 2024

@sethjgore That's a good guess. Thank you!
I don't have this issue when using Postgres. Unique index is not on local_id only but on [table, local_id].
Which database are you using ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants