strapi-plugin-config-sync: [BUG] Database error when trying to delete the `strapi-super-admin` role & an i18n locale at the same time
Bug report
We are testing this plugin in order to avoid additional steps to duplicate our development admin to production.
Importing all the updated files from a previous environment, we found this bug.
[2022-08-13 18:48:57.435] error: error: insert into "admin_permissions" ("action", "conditions", "created_at", "id", "properties", "subject", "updated_at") values ($1, $2, $3, $4, $5, $6, $7) returning "id" - duplicate key value violates unique constraint "admin_permissions_pkey"
Error: error: insert into "admin_permissions" ("action", "conditions", "created_at", "id", "properties", "subject", "updated_at") values ($1, $2, $3, $4, $5, $6, $7) returning "id" - duplicate key value violates unique constraint "admin_permissions_pkey"
at Object.importSingleConfig (/srv/app/node_modules/strapi-plugin-config-sync/server/services/main.js:234:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /srv/app/node_modules/strapi-plugin-config-sync/server/controllers/config.js:57:7
at async Promise.all (index 9)
at async Object.importAll (/srv/app/node_modules/strapi-plugin-config-sync/server/controllers/config.js:56:5)
at async returnBodyMiddleware (/srv/app/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
at async policiesMiddleware (/srv/app/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5)
at async transform (/srv/app/node_modules/strapi-plugin-transformer/server/middleware/transform.js:9:2)
at async /srv/app/node_modules/@strapi/strapi/lib/middlewares/body.js:51:9
at async /srv/app/node_modules/@strapi/strapi/lib/middlewares/logger.js:22:5
at async /srv/app/node_modules/@strapi/strapi/lib/middlewares/powered-by.js:16:5
at async cors (/srv/app/node_modules/@koa/cors/index.js:95:16)
at async /srv/app/node_modules/@strapi/strapi/lib/middlewares/errors.js:13:7
at async session (/srv/app/node_modules/koa-session/index.js:41:7)
at async /srv/app/node_modules/@strapi/strapi/lib/services/metrics/middleware.js:29:5
Steps to reproduce the behavior
- Go to Config > Config Sync > Tool.
- Click on Import.
- Look at the toast with the warning.
- Go to container logs and find the bug.
- Go to Content Management.
- Look at some of the models that are missing.
- Come back to Config > Config Sync > Tool.
- Click on Import again.
- Look at a toast with everything working well.
- Go back to Content Management.
- Find the missing models on the admin.
Expected behavior
It would not show any problem at importing configuration.
Screenshots
If applicable, add screenshots to help explain your problem.
Code snippets
If applicable, add code samples to help explain your problem.
System
- Node.js version: 4.3.2 (node v14.20.0)
- Strapi version: 4.3.2
- Plugin version: 2.0.8
- Database: PostgreSQL 13.7
- Operating system: Alpine Linux v3.16
Additional context
Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (9 by maintainers)
Allright thanks. I’ll try importing locally
I’ve written an exception to forbid deletion of the super-admin role which will fix this problem. See commit.
This was released with v1.1.0 of the plugin.
Confirmed that this doesn’t happend with sqlite, but does happend with postgres.
Allright. I believe what you’re describing is a different issue from this one. If you wan’t to submit a new issue for that that’s fine.
As for the issue we’re commenting on right now, I think this can be prevented by just not deleting the strapi-super-admin role. I don’t see any reason why you would want to do that anyways.