Baboo7 / strapi-plugin-import-export-entries

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

[BUG] Error 500 while importing when using postgres #113

Closed rtkac closed 1 year ago

rtkac commented 1 year ago

I can see 500 error response while uploading when using postgres database: {"data":null,"error":{"status":500,"name":"InternalServerError","message":"Internal Server Error"}}

Body payload: {"slug":"custom:db","data":"{\n\t\"version\": 2,\n\t\"data\": {\n\t\t\"plugin::upload.folder\": {},\n\t\t\"plugin::upload.file\": {},\n\t\t\"api::test1.test1\": {\n\t\t\t\"1\": {\n\t\t\t\t\"id\": 1,\n\t\t\t\t\"name1\": \"test 1 name\",\n\t\t\t\t\"createdAt\": \"2023-04-24T07:54:55.073Z\",\n\t\t\t\t\"updatedAt\": \"2023-04-24T07:54:55.073Z\",\n\t\t\t\t\"publishedAt\": null,\n\t\t\t\t\"media1\": null,\n\t\t\t\t\"createdBy\": null,\n\t\t\t\t\"updatedBy\": null\n\t\t\t}\n\t\t}\n\t}\n}","format":"json","idField":"id"}

Do you know what could be a problem?

FYI:

Thanks!

Baboo7 commented 1 year ago

@rtkac do you have any server logs?

rtkac commented 1 year ago

Hi, here are the server logs:

[2023-04-24 20:32:16.173] http: GET /import-export-entries/import/model-attributes/custom:db (34 ms) 200
[2023-04-24 20:32:19.646] error: Cannot read properties of undefined (reading 'modelType')
TypeError: Cannot read properties of undefined (reading 'modelType')
    at /opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:83:104
    at Array.filter (<anonymous>)
    at extract (/opt/node_modules/strapi-plugin-import-export-entries/libs/arrays.js:27:33)
    at splitSlugs (/opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:83:49)
    at /opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:48:62
    at Generator.next (<anonymous>)
    at /opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:4:12)
    at Object.importDataV2 (/opt/node_modules/strapi-plugin-import-export-entries/server/services/import/import-v2.js:43:74)
    at Object.<anonymous> (/opt/node_modules/strapi-plugin-import-export-entries/server/controllers/admin/import-controller/import-data.js:26:46)
    at Generator.next (<anonymous>)
    at fulfilled (/opt/node_modules/strapi-plugin-import-export-entries/server/controllers/admin/import-controller/import-data.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-04-24 20:32:19.689] http: GET /import-export-entries/import/model-attributes/custom:db (29 ms) 200
p8ul commented 1 year ago

I'm getting the same issue. I'm migrating data from Strapi v4.5.2 to v4.90 using strapi-plugin-import-export-entries v1.19.0

Baboo7 commented 1 year ago

Fixed in 1.19.1

rtkac commented 1 year ago

@Baboo7 Thanks!

  1. works fine when I import content for collection type that exists in the admin
  2. doesn't work when I import collection type with content that doesn't exist in the admin

Should work in both situations, right? :D

Baboo7 commented 1 year ago

Import should work only if the collection type is known by the app. I haven't tested importing data for a collection that hasn't been created before, and actually unknown slugs are ignored

rtkac commented 1 year ago

OK thanks. So it looks like it's working now :)

What do you think about this feature mentioned in point 2.? Is it realistic? It will be great to have such a functionality (to import collection type with its data).

Baboo7 commented 1 year ago

It looks interesting but it requires a lot of investigation to see how strapi handles the creation of a new collection. Plus a change in how data is exported at the moment, which is not the main blocking part. We'll see how many times this feature will be requested

hdeadman commented 1 year ago

Regarding the sync of content model along with content, sounds like a bad idea. The content model is code and this is a plugin for moving content. Content model changes should be managed as code (e.g. version control, etc), especially since they are creating tables in a database.