Baboo7 / strapi-plugin-import-export-entries

Import/Export data from and to your database in just few clicks.
175 stars 86 forks source link

[BUG] Getting error "level": "\u001b[31merror\u001b[39m" on importing users #160

Open molul opened 9 months ago

molul commented 9 months ago

Describe the bug I'm testing exporting from my Strapi deployment and importing on my local build, just as a security routine task, and I've been able to import everything except for "plugin::users-permissions.role" data. When I try to import I get the error mentioned in the title (there's a screenshot below).

To Reproduce Steps to reproduce the behavior:

  1. Exported a big Strapi database (several hundreds users and collections items), in two steps as usual, one from "Content manager -> Users" to get the users (I'll call it the "users" file) and one from the main "Import Export" option in the sidebar menu to get the rest of the content (the "content" file).
  2. Imported both files. The "contents" file imported successfully, but the "users" file didn't. I split it in three smaller files to see if the problem is with the file size (it's not), each file having the contents for "plugin::users-permissions.user", "plugin::users-permissions.permission" and "plugin::users-permissions.role". The file that fails is the last one, users-permissions.role.
  3. See error described above.

Expected behavior I expected the data to import fine as in previous attempts.

Screenshots Here's a screenshot of the message: image

Additional context I updated my local Strapi build to the latest version (4.15.5) but kept strapi-plugin-import-export-entries on version 1.18.0. The Strapi deployed in Railway was still on 4.11.1 when I exported the entries.

But then I rolled my local Strapi build back to the previous version (4.11.1) and I get the same error.

If it helps, this is the json file content that's throwing the error:

backupusers3.json

molul commented 9 months ago

Maybe this error I'm seeing in the log helps to troubleshoot the issue:

[2023-12-09 19:57:25.121] error: insert into up_users_role_links (role_id, user_id, user_order) select 1 as role_id, 1 as user_id, 1 as user_order union all select 1 as role_id, 6 as user_id, 2 as user_order union all ... (repeats for several hundreds of entries) ... union all select 1 as role_id, 658 as user_id, 512 as user_order union all select 1 as role_id, 659 as user_id, 513 as user_order where true on conflict (user_id, role_id) do update set user_order = excluded.user_order returning id - too many terms in compound SELECT

SqliteError: insert into up_users_role_links (role_id, user_id, user_order) select 1 as role_id, 1 as user_id, 1 as user_order union all select 1 as role_id, 6 as user_id, 2 as user_order union all select 1 as role_id, 43 as user_id, 3 as user_order union all ... (repeats for several hundreds of entries) ... union all select 1 as role_id, 659 as user_id, 513 as user_order where true on conflict (user_id, role_id) do update set user_order = excluded.user_order returning id - too many terms in compound SELECT at Database.prepare (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21) at Client_BetterSQLite3._query (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/dialects/better-sqlite3/index.js:30:34) at executeQuery (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/internal/query-executioner.js:37:17) at Client_BetterSQLite3.query (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/client.js:146:12) at /Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/transaction.js:363:24 at new Promise () at trxClient.query (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/transaction.js:358:12) at Runner.query (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/runner.js:123:36) at ensureConnectionCallback (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17) at Runner.ensureConnection (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/runner.js:300:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Runner.run (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/knex/lib/execution/runner.js:30:19) at async Object.execute (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/@strapi/database/lib/query/query-builder.js:481:22) at async Object.updateRelations (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/@strapi/database/lib/entity-manager/index.js:1023:15) at async Object.update (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/@strapi/database/lib/entity-manager/index.js:317:9) at async Object.update (/Users/luis/Desktop/Work/Dev/NextJS/buscamusicos/repos/buscamusicos-cms/node_modules/@strapi/strapi/lib/services/entity-service/index.js:222:18) [2023-12-09 19:57:25.139] http: POST /import-export-entries/import (67200 ms) 200

amityweb commented 7 months ago

I often get this too its frustrating. Only for some errors. I forget the error may be in the console log and so spend ages debugging until I remember! Would be great if the import popup actually shows the error. OR just say "Look in the console" to remind us :joy:

{ "error": { "level": "\u001b[31merror\u001b[39m", "timestamp": "2024-01-13 16:09:35.244" }, "data": { "id": 324, "title": "ROHS và REACH", "craftId": "710512-vi", "Sections": [ 324 ], "slug": "trách-nhiệm/rohs-reach", "Accordion": null, "Links": null, "locale": "vi", "localizations": [ 30 ], "createdAt": "2020-01-09T15:00:14.000Z", "updatedAt": "2023-09-18T12:50:59.000Z", "publishedAt": "2020-01-09T14:55:00.000Z", "createdBy": 4, "updatedBy": 4 } },

Console showed this as the error:

[2024-01-13 16:09:35.244] error: Could not find default locale entry to import localization for slug api::page.page (data {"title":"ROHS và REACH","slug":"trách-nhiệm/rohs-reach","craftId":"710512-vi","Accordion":null,"Links":null,"Sections":[],"createdAt":"2020-01-09T15:00:14.000Z","updatedAt":"2023-09-18T12:50:59.000Z","publishedAt":"2020-01-09T14:55:00.000Z","locale":"vi","id":324})

juliana-zhu commented 5 months ago

I also encountered the same problem, but I don't know where the problem is. I hope there is a solution.

Error: Could not find default locale entry to import localization

amityweb commented 5 months ago

I also encountered the same problem, but I don't know where the problem is. I hope there is a solution.

Error: Could not find default locale entry to import localization

In my case it was because the import was either missing the localizations array of ID numbers of the equivalent default localization entry, or I referenced a default localization ID that did not exist. I think it was the second one one, I did not have the equivalent page in the default language because I can see the localization array in my data above, so can only assume it means a page with ID 30 was not setup in the default language.

jonathanafranio commented 3 months ago

I also have the same problem:

[
    {
        "error": {
            "level": "\u001b[31merror\u001b[39m",
            "timestamp": "2024-05-09 09:34:01.493"
        },
        "data": {
            "id": 157,
            "name": "Teste 09/05/2024",
            "data_inicio": "2024-03-23",
            "data_fim": "2024-12-23",
            "especialidade": "Cirurgia e Traumatologia Buco Maxilo Faciais| Cirurgia Cranio-Maxilo-Facial",
            "legenda": "<p>Dr. Rafael de Miranda Alves médico e dentista especializado em Cirurgia e Traumatologia Buco Maxilo Facial. Realizou especialização em Cirurgia Ortognatica, ATM e Craniofacial em Childrens Medical Center Dallas.</p>",
            "endereco": "RUA TRÊS IRMÃOS, 310 - 4 ANDAR - CJ 403 - VILA PROGREDIOR, SÃO PAULO/SP. CEP: 05615-190",
            "createdAt": "2024-05-08T19:10:07.286Z",
            "updatedAt": "2024-05-08T19:10:11.375Z",
            "publishedAt": "2024-05-08T19:10:11.368Z",
            "link_credenciado": "null",
            "sitemap_exclude": false,
            "Tipo_Contato": "Número com 11 Dígitos (DDD + 9 dígitos)",
            "whatsapp": true,
            "contato": "11990217260",
            "peso": "113",
            "cidade": 5349,
            "createdBy": null,
            "updatedBy": null
        }
    }
]