strapi-plugin-config-sync icon indicating copy to clipboard operation
strapi-plugin-config-sync copied to clipboard

[BUG] Database error when trying to delete the `strapi-super-admin` role & an i18n locale at the same time

Open SalahAdDin opened this issue 3 years ago • 15 comments

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

  1. Go to Config > Config Sync > Tool.
  2. Click on Import.
  3. Look at the toast with the warning.
  4. Go to container logs and find the bug.
  5. Go to Content Management.
  6. Look at some of the models that are missing.
  7. Come back to Config > Config Sync > Tool.
  8. Click on Import again.
  9. Look at a toast with everything working well.
  10. Go back to Content Management.
  11. 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.

SalahAdDin avatar Aug 13 '22 19:08 SalahAdDin

Hi @SalahAdDin,

Thanks for submitting the issue. Could you please provide the exact config changes you are trying to import? I can’t reproduce the issue like this. Maby an explanation on how you got to this point could help as wel.

boazpoolman avatar Aug 13 '22 21:08 boazpoolman

All of them are about localization options as follows: Screen Shot 2022-08-14 at 18 55 09

I'm attaching the specific file: admin-role.strapi-super-admin.txt

SalahAdDin avatar Aug 14 '22 15:08 SalahAdDin

Allright thanks. I’ll try importing locally

boazpoolman avatar Aug 14 '22 18:08 boazpoolman

Allright thanks. I’ll try importing locally

I'm testing this plugin with the 4.3.4 version and it is more broken, I cannot recover the missing models on the Content Manager:

Uncaught (in promise) Error: Network Error
    exports http://localhost:1337/admin/main.e371d6f0.js:13812
    onerror http://localhost:1337/admin/main.e371d6f0.js:13812
    exports http://localhost:1337/admin/main.e371d6f0.js:13812
    exports http://localhost:1337/admin/main.e371d6f0.js:13812
    exports http://localhost:1337/admin/main.e371d6f0.js:13812
    request http://localhost:1337/admin/main.e371d6f0.js:13812
    d http://localhost:1337/admin/main.e371d6f0.js:13812
    exports http://localhost:1337/admin/main.e371d6f0.js:13812
    current http://localhost:1337/admin/main.e371d6f0.js:13797
    Rt http://localhost:1337/admin/Admin-authenticatedApp.96f8448c.chunk.js:80
    Qm http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    gc http://localhost:1337/admin/main.e371d6f0.js:18182
    Og http://localhost:1337/admin/main.e371d6f0.js:18182
    q http://localhost:1337/admin/main.e371d6f0.js:18232
    onmessage http://localhost:1337/admin/main.e371d6f0.js:18232
    60053 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    63840 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    64448 http://localhost:1337/admin/main.e371d6f0.js:18174
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    73935 http://localhost:1337/admin/main.e371d6f0.js:18182
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    74617 http://localhost:1337/admin/main.e371d6f0.js:17009
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    S http://localhost:1337/admin/main.e371d6f0.js:18379
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:18379
    i http://localhost:1337/admin/runtime~main.167116aa.js:2
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:1
Screen Shot 2022-08-14 at 22 14 55 Screen Shot 2022-08-14 at 22 13 55

And the new one is, coming to some setting pages, we are getting the next bug and a blank page:

TypeError: B is null
    Z http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    fd http://localhost:1337/admin/main.e371d6f0.js:18178
    uc http://localhost:1337/admin/main.e371d6f0.js:18178
    Mg http://localhost:1337/admin/main.e371d6f0.js:18182
    Gm http://localhost:1337/admin/main.e371d6f0.js:18182
    rh http://localhost:1337/admin/main.e371d6f0.js:18182
    nh http://localhost:1337/admin/main.e371d6f0.js:18182
    pc http://localhost:1337/admin/main.e371d6f0.js:18180
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    cl http://localhost:1337/admin/main.e371d6f0.js:18178
    jl http://localhost:1337/admin/main.e371d6f0.js:18180
    Kf http://localhost:1337/admin/main.e371d6f0.js:18178
    q http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    G http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    promise callback*B http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Y http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Y http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    q http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Z http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Qm http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    gc http://localhost:1337/admin/main.e371d6f0.js:18182
    Og http://localhost:1337/admin/main.e371d6f0.js:18182
    q http://localhost:1337/admin/main.e371d6f0.js:18232
    onmessage http://localhost:1337/admin/main.e371d6f0.js:18232
    60053 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    63840 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    64448 http://localhost:1337/admin/main.e371d6f0.js:18174
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    73935 http://localhost:1337/admin/main.e371d6f0.js:18182
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    74617 http://localhost:1337/admin/main.e371d6f0.js:17009
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    S http://localhost:1337/admin/main.e371d6f0.js:18379
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:18379
    i http://localhost:1337/admin/runtime~main.167116aa.js:2
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:1
[main.e371d6f0.js:18180:71](http://localhost:1337/admin/main.e371d6f0.js)
    np http://localhost:1337/admin/main.e371d6f0.js:18180
    callback http://localhost:1337/admin/main.e371d6f0.js:18180
    jf http://localhost:1337/admin/main.e371d6f0.js:18178
    op http://localhost:1337/admin/main.e371d6f0.js:18180
    Ym http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    zl http://localhost:1337/admin/main.e371d6f0.js:18182
    pc http://localhost:1337/admin/main.e371d6f0.js:18180
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    cl http://localhost:1337/admin/main.e371d6f0.js:18178
    jl http://localhost:1337/admin/main.e371d6f0.js:18180
    Kf http://localhost:1337/admin/main.e371d6f0.js:18178
    q http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    G http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    (Async: promise callback)
    B http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Y http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Y http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    q http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Z http://localhost:1337/admin/upload-settings.224ef300.chunk.js:101
    Qm http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    gc http://localhost:1337/admin/main.e371d6f0.js:18182
    Og http://localhost:1337/admin/main.e371d6f0.js:18182
    q http://localhost:1337/admin/main.e371d6f0.js:18232
    onmessage http://localhost:1337/admin/main.e371d6f0.js:18232
    (Async: EventHandlerNonNull)
    60053 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    63840 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    64448 http://localhost:1337/admin/main.e371d6f0.js:18174
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    73935 http://localhost:1337/admin/main.e371d6f0.js:18182
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    74617 http://localhost:1337/admin/main.e371d6f0.js:17009
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    S http://localhost:1337/admin/main.e371d6f0.js:18379
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:18379
    i http://localhost:1337/admin/runtime~main.167116aa.js:2
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:1
Screen Shot 2022-08-14 at 22 21 00
TypeError: N is null
    oe http://localhost:1337/admin/users-advanced-settings-page.9c074931.chunk.js:101
    W http://localhost:1337/admin/main.e371d6f0.js:18121
    fd http://localhost:1337/admin/main.e371d6f0.js:18178
    Mg http://localhost:1337/admin/main.e371d6f0.js:18182
    Gm http://localhost:1337/admin/main.e371d6f0.js:18182
    rh http://localhost:1337/admin/main.e371d6f0.js:18182
    nh http://localhost:1337/admin/main.e371d6f0.js:18182
    pc http://localhost:1337/admin/main.e371d6f0.js:18180
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    cl http://localhost:1337/admin/main.e371d6f0.js:18178
    wd http://localhost:1337/admin/main.e371d6f0.js:18180
    flush http://localhost:1337/admin/main.e371d6f0.js:18204
    promise callback*Y http://localhost:1337/admin/main.e371d6f0.js:18204
    flush http://localhost:1337/admin/main.e371d6f0.js:18204
    batch http://localhost:1337/admin/main.e371d6f0.js:18204
    dispatch http://localhost:1337/admin/main.e371d6f0.js:18204
    setData http://localhost:1337/admin/main.e371d6f0.js:18204
    onSuccess http://localhost:1337/admin/main.e371d6f0.js:18204
    L http://localhost:1337/admin/main.e371d6f0.js:18204
    promise callback*f http://localhost:1337/admin/main.e371d6f0.js:18204
    s http://localhost:1337/admin/main.e371d6f0.js:18204
    fetch http://localhost:1337/admin/main.e371d6f0.js:18204
    executeFetch http://localhost:1337/admin/main.e371d6f0.js:18204
    onSubscribe http://localhost:1337/admin/main.e371d6f0.js:18204
    subscribe http://localhost:1337/admin/main.e371d6f0.js:18204
    i http://localhost:1337/admin/main.e371d6f0.js:18204
    Qm http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    gc http://localhost:1337/admin/main.e371d6f0.js:18182
    Og http://localhost:1337/admin/main.e371d6f0.js:18182
    q http://localhost:1337/admin/main.e371d6f0.js:18232
    onmessage http://localhost:1337/admin/main.e371d6f0.js:18232
    60053 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    63840 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    64448 http://localhost:1337/admin/main.e371d6f0.js:18174
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    73935 http://localhost:1337/admin/main.e371d6f0.js:18182
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    74617 http://localhost:1337/admin/main.e371d6f0.js:17009
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    S http://localhost:1337/admin/main.e371d6f0.js:18379
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:18379
    i http://localhost:1337/admin/runtime~main.167116aa.js:2
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:1
[main.e371d6f0.js:18180:71](http://localhost:1337/admin/main.e371d6f0.js)
    np http://localhost:1337/admin/main.e371d6f0.js:18180
    callback http://localhost:1337/admin/main.e371d6f0.js:18180
    jf http://localhost:1337/admin/main.e371d6f0.js:18178
    op http://localhost:1337/admin/main.e371d6f0.js:18180
    Ym http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    zl http://localhost:1337/admin/main.e371d6f0.js:18182
    pc http://localhost:1337/admin/main.e371d6f0.js:18180
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    pg http://localhost:1337/admin/main.e371d6f0.js:18178
    cl http://localhost:1337/admin/main.e371d6f0.js:18178
    wd http://localhost:1337/admin/main.e371d6f0.js:18180
    flush http://localhost:1337/admin/main.e371d6f0.js:18204
    (Async: promise callback)
    Y http://localhost:1337/admin/main.e371d6f0.js:18204
    flush http://localhost:1337/admin/main.e371d6f0.js:18204
    batch http://localhost:1337/admin/main.e371d6f0.js:18204
    dispatch http://localhost:1337/admin/main.e371d6f0.js:18204
    setData http://localhost:1337/admin/main.e371d6f0.js:18204
    onSuccess http://localhost:1337/admin/main.e371d6f0.js:18204
    L http://localhost:1337/admin/main.e371d6f0.js:18204
    (Async: promise callback)
    f http://localhost:1337/admin/main.e371d6f0.js:18204
    s http://localhost:1337/admin/main.e371d6f0.js:18204
    fetch http://localhost:1337/admin/main.e371d6f0.js:18204
    executeFetch http://localhost:1337/admin/main.e371d6f0.js:18204
    onSubscribe http://localhost:1337/admin/main.e371d6f0.js:18204
    subscribe http://localhost:1337/admin/main.e371d6f0.js:18204
    i http://localhost:1337/admin/main.e371d6f0.js:18204
    Qm http://localhost:1337/admin/main.e371d6f0.js:18182
    unstable_runWithPriority http://localhost:1337/admin/main.e371d6f0.js:18232
    od http://localhost:1337/admin/main.e371d6f0.js:18178
    gc http://localhost:1337/admin/main.e371d6f0.js:18182
    Og http://localhost:1337/admin/main.e371d6f0.js:18182
    q http://localhost:1337/admin/main.e371d6f0.js:18232
    onmessage http://localhost:1337/admin/main.e371d6f0.js:18232
    (Async: EventHandlerNonNull)
    60053 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    63840 http://localhost:1337/admin/main.e371d6f0.js:18232
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    64448 http://localhost:1337/admin/main.e371d6f0.js:18174
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    73935 http://localhost:1337/admin/main.e371d6f0.js:18182
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    74617 http://localhost:1337/admin/main.e371d6f0.js:17009
    s http://localhost:1337/admin/runtime~main.167116aa.js:1
    S http://localhost:1337/admin/main.e371d6f0.js:18379
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:18379
    i http://localhost:1337/admin/runtime~main.167116aa.js:2
    <anonymous> http://localhost:1337/admin/main.e371d6f0.js:1

SalahAdDin avatar Aug 14 '22 19:08 SalahAdDin

It is going deeper, @boazpoolman should I open an issue with all 4.3.4 bugs I am finding?

SalahAdDin avatar Aug 14 '22 19:08 SalahAdDin

Trying to avoid such a problem with that configuration by removing it from the configuration files, well, it deleted all my super admin privileges and now I can't do anything.

SalahAdDin avatar Aug 14 '22 19:08 SalahAdDin

It seems all of these things are happening for the same reason. Please don't report more issues about this.

I have been able to reproduce your issue by doing this:

  • Fresh install of Strapi v4.3.2
  • Install config-sync plugin
  • Do the initial export
  • Delete all files in the config/sync dir
  • Do an import

We now have effectively deleted all the config in our DB. This should go succesfull, but for me it gave me an error when trying to delete the super-admin role.

database_1  | 2022-08-15 07:06:52.724 UTC [41] ERROR:  insert or update on table "admin_permissions_role_links" violates foreign key constraint "admin_permissions_role_links_inv_fk"
database_1  | 2022-08-15 07:06:52.724 UTC [41] DETAIL:  Key (role_id)=(1) is not present in table "admin_roles".
database_1  | 2022-08-15 07:06:52.724 UTC [41] STATEMENT:  insert into "admin_permissions_role_links" ("permission_id", "role_id") values ($1, $2)
database_1  | 2022-08-15 07:06:52.728 UTC [42] ERROR:  duplicate key value violates unique constraint "admin_permissions_pkey"
database_1  | 2022-08-15 07:06:52.728 UTC [42] DETAIL:  Key (id)=(52) already exists.
database_1  | 2022-08-15 07:06:52.728 UTC [42] STATEMENT:  insert into "admin_permissions" ("action", "conditions", "created_at", "id", "properties", "subject", "updated_at") values ($1, $2, $3, $4, $5, $6, $7) returning "id"

The same error you have.

I feel like you accidentally deleted the super-admin role which has corrupted your DB. You could maby check to see if the admin-role.strapi-super-admin.json file is present in your git repo.

I fixed the issue by doing this:

  • Restart Strapi
  • Run an export

Though your DB might be more complex and can't be fixed like this. I would suggest to ask for a DB dump of a colleage, or grab one from another environment, or maby a backup and import that in your local environment.

boazpoolman avatar Aug 15 '22 07:08 boazpoolman

It seems all of these things are happening for the same reason. Please don't report more issues about this.

I have been able to reproduce your issue by doing this:

* Fresh install of Strapi v4.3.2

* Install config-sync plugin

* Do the initial export

* Delete all files in the `config/sync` dir

* Do an import

We now have effectively deleted all the config in our DB. This should go successful, but for me, it gave me an error when trying to delete the super-admin role.

database_1  | 2022-08-15 07:06:52.724 UTC [41] ERROR:  insert or update on table "admin_permissions_role_links" violates foreign key constraint "admin_permissions_role_links_inv_fk"
database_1  | 2022-08-15 07:06:52.724 UTC [41] DETAIL:  Key (role_id)=(1) is not present in table "admin_roles".
database_1  | 2022-08-15 07:06:52.724 UTC [41] STATEMENT:  insert into "admin_permissions_role_links" ("permission_id", "role_id") values ($1, $2)
database_1  | 2022-08-15 07:06:52.728 UTC [42] ERROR:  duplicate key value violates unique constraint "admin_permissions_pkey"
database_1  | 2022-08-15 07:06:52.728 UTC [42] DETAIL:  Key (id)=(52) already exists.
database_1  | 2022-08-15 07:06:52.728 UTC [42] STATEMENT:  insert into "admin_permissions" ("action", "conditions", "created_at", "id", "properties", "subject", "updated_at") values ($1, $2, $3, $4, $5, $6, $7) returning "id"

The same error you have.

I feel like you accidentally deleted the super-admin role which has corrupted your DB. You could maybe check to see if the admin-role.strapi-super-admin.json file is present in your git repo.

I fixed the issue by doing this:

* Restart Strapi

* Run an export

Though your DB might be more complex and can't be fixed like this. I would suggest asking for a DB dump of a colleague, grabbing one from another environment, or maybe a backup and importing that into your local environment.

Well, yes, I deleted such file, the json file, and I did all the processes again.

But it didn't fix all the problems, I got other bugs, specifically when importing the files, I got an internal server error response, but it imported all wanted configurations.

Should I create a new issue about it?

SalahAdDin avatar Aug 15 '22 09:08 SalahAdDin

Yes. For the internal server error please create another issue.

As for this issue; I'll rename it to be about an error when the super-admin role is deleted.

boazpoolman avatar Aug 15 '22 10:08 boazpoolman

After adding some more logging I found out the issue occurred when trying to import (delete) the i18n-locale.en config. But only after we've deleted the strapi-super-admin role.

Schermafbeelding 2022-08-15 om 13 26 44

Though I must say. This is really an edge case... You shouldn't go and try to delete all the config from your DB, and def not all at once. No real world usecase for that.

EDIT:

More narrowed down steps to reproduce:

  • Fresh install of Strapi 4.3.x
  • Install config-sync plugin
  • Run the initial export
  • Delete all files in the config/sync/ directory (don't delete the directory itself)
  • Run yarn cs i -p admin-role.strapi-super-admin,i18n-locale.en -y
  • See the error as screenshotted above in this comment.

boazpoolman avatar Aug 15 '22 11:08 boazpoolman

After adding some more logging I found out the issue occurred when trying to import (delete) the i18n-locale.en config. But only after we've deleted the strapi-super-admin role.

Schermafbeelding 2022-08-15 om 13 26 44

Though I must say. This is really an edge case... You shouldn't go and try to delete all the config from your DB, and def not all at once. No real world usecase for that.

EDIT:

More narrowed down steps to reproduce:

* Fresh install of Strapi 4.3.x

* Install config-sync plugin

* Run the initial export

* Delete all files in the `config/sync/` directory (don't delete the directory itself)

* Run `yarn cs i -p admin-role.strapi-super-admin,i18n-locale.en -y`

* See the error as screenshotted above in this comment.

Yeah, we realized about it, but even leaving the English file, removing strapi super admin just gives step to other issues, with the 4.3.4 version.

SalahAdDin avatar Aug 15 '22 11:08 SalahAdDin

Hmmz allright. Maby I'll just remove the possibility of deleting the strapi-super-admin role. As it's super useless and wil fix all of these issues.

boazpoolman avatar Aug 15 '22 12:08 boazpoolman

Hmm alright. Maby I'll just remove the possibility of deleting the strapi-super-admin role. As it's super useless and will fix all of these issues.

I don't think it is related to superadmin, cause, as I told you, I deleted it and I tried to reimport only, only!, my content models configuration, and even so I got a problem even when the configuration is imported.

SalahAdDin avatar Aug 15 '22 12:08 SalahAdDin

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.

boazpoolman avatar Aug 15 '22 12:08 boazpoolman

Confirmed that this doesn't happend with sqlite, but does happend with postgres.

boazpoolman avatar Aug 18 '22 08:08 boazpoolman

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.

boazpoolman avatar Dec 06 '22 09:12 boazpoolman