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

[BUG] Can't import entire db when using postgres #89

Closed
landoephan opened this issue Dec 8, 2022 · 21 comments
Closed

[BUG] Can't import entire db when using postgres #89

landoephan opened this issue Dec 8, 2022 · 21 comments
Assignees

Comments

@landoephan
Copy link

Describe the bug
When I export the entire db from a postgres db and try to import it again I get a 403 error on POST /import-export-entries/import and a 500 error afterwards on GET http://localhost:1337/import-export-entries/import/model-attributes/custom:db

The logs from my strapi application look like this:

[2022-12-08 14:43:41.957] error: Cannot read properties of undefined (reading 'attributes')
TypeError: Cannot read properties of undefined (reading 'attributes')
    at getModelAttributes (.../node_modules/strapi-plugin-import-export-entries/server/utils/models.js:89:46)
    at Object.getModelAttributesEndpoint [as getModelAttributes] (.../node_modules/strapi-plugin-import-export-entries/server/controllers/admin/import-controller/get-model-attributes.js:8:26)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at returnBodyMiddleware (.../node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:24)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at policiesMiddleware (.../node_modules/@strapi/strapi/lib/services/server/policy.js:24:11)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at .../node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:33:12
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-12-08 14:43:46.827] http: POST /import-export-entries/import (37 ms) 403
[2022-12-08 14:43:46.857] error: Cannot read properties of undefined (reading 'attributes')
TypeError: Cannot read properties of undefined (reading 'attributes')
    at getModelAttributes (.../node_modules/strapi-plugin-import-export-entries/server/utils/models.js:89:46)
    at Object.getModelAttributesEndpoint [as getModelAttributes] (.../node_modules/strapi-plugin-import-export-entries/server/controllers/admin/import-controller/get-model-attributes.js:8:26)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at returnBodyMiddleware (.../node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:24)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at policiesMiddleware (.../node_modules/@strapi/strapi/lib/services/server/policy.js:24:11)
    at dispatch (.../node_modules/koa-compose/index.js:42:32)
    at .../node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:33:12
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

In the browser console I'm getting the following error messages:

main.a5adda14.js:9121          GET http://localhost:1337/import-export-entries/import/model-attributes/custom:db 500 (Internal Server Error)
...
main.a5adda14.js:9121 Uncaught (in promise) Error: Internal Server Error
    at main.a5adda14.js:9121:12290
(anonymous) @ main.a5adda14.js:9121
...
main.a5adda14.js:9121          POST http://localhost:1337/import-export-entries/import 403 (Forbidden)
Tr @ main.a5adda14.js:9121
...
main.a5adda14.js:9121          GET http://localhost:1337/import-export-entries/import/model-attributes/custom:db 500 (Internal Server Error)
...
main.a5adda14.js:9121 Uncaught (in promise) Error: Internal Server Error
    at main.a5adda14.js:9121:12290

Three requests are made:
1.

Request URL: http://localhost:1337/import-export-entries/import/model-attributes/custom:db
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:1337
Referrer Policy: no-referrer
Request URL: http://localhost:1337/import-export-entries/import
Request Method: POST
Status Code: 403 Forbidden
Remote Address: 127.0.0.1:1337
Referrer Policy: no-referrer
Request URL: http://localhost:1337/import-export-entries/import/model-attributes/custom:db
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:1337
Referrer Policy: no-referrer

To Reproduce
Steps to reproduce the behavior:

  1. Go to http://localhost:1337/admin/plugins/import-export-entries
  2. Click on export --> fetch data --> Download file --> save file
  3. Click on import --> select the saved file --> import
  4. See error in browser console and application logs

Expected behavior
The import from a complete db export works. The data is imported in the database and visible in the admin panel

Additional context
Version: "strapi-plugin-import-export-entries": "^1.18.0"

database version: "pg": "^8.8.0"

I'm a superuser in my postgres db

@mikebcbc
Copy link

mikebcbc commented Dec 8, 2022

I'm encountering the same issue.

@mikebcbc
Copy link

mikebcbc commented Dec 8, 2022

@landoephan one workaround that just worked for me is individually importing/exporting each model instead of the whole DB at once. I was able to import it all, just a tad more tediously. Maybe that'll work for you too?

@landoephan
Copy link
Author

@mikebcbc I tried that, too, but then I have another problem, see #88. Maybe you could check, if you're encountering that problem, too?

@VrTech
Copy link

VrTech commented Dec 9, 2022

Same problem here cannot import when using postgres

@gfsd3v
Copy link

gfsd3v commented Dec 10, 2022

Same here.

@cooperwfloyd
Copy link

same problem here. exporting from Postgres is successful, but when importing locally into the default SQLite database is when that same TypeError: Cannot read properties of undefined (reading 'attributes') at getModelAttributes error comes up

@mbkkong
Copy link

mbkkong commented Dec 14, 2022

+10

@hpmax00
Copy link

hpmax00 commented Dec 19, 2022

+1

@sts-ryan-holton
Copy link

Experiencing the same thing

@JoshuaRobertson
Copy link

I'm experiencing the same issue as a Super Admin. After selecting a file it throws a 500 error for custom:db and then when attempting an import it results in a 403 error. The only difference for my project is I'm using MariaDB instead of postgres.

Could this be related to the recent Strapi CMS update and a change in user permissions?

@rgouzal
Copy link

rgouzal commented Jan 1, 2023

@landoephan one workaround that just worked for me is individually importing/exporting each model instead of the whole DB at once. I was able to import it all, just a tad more tediously. Maybe that'll work for you too?

When you imported the DB , what deepness level you set or you set it to none?

@landoephan
Copy link
Author

I can't test it at the moment since strapi always crashes after a while of loading. I guess my database became too big already

@rgouzal
Copy link

rgouzal commented Jan 5, 2023

I can't test it at the moment since strapi always crashes after a while of loading. I guess my database became too big already

@landoephan I did came across that too

@cyruskorn
Copy link

Same here. Tried to import locally on a SQLite database, and on a PostgreSQL database. Neither worked.

@oyenigun
Copy link

Same here.
When i tried to export and import on Content Manager for one collection it succeed.
Export whole database is working but import whole database is not working.

@molul
Copy link

molul commented Mar 21, 2023

+1. Production db is postgres, development is sqlite, I can export from production but can't import to development. I see the same errors mentioned in the first post.

@rtkac
Copy link

rtkac commented Apr 22, 2023

Same issue here.
Export from postgres is working fine, but import the same exported JSON to postgres failed.
error: Cannot read properties of undefined (reading 'attributes')

@Baboo7
Copy link
Owner

Baboo7 commented Apr 23, 2023

This issue is fixed in version 1.19.0!

@Baboo7 Baboo7 closed this as completed Apr 23, 2023
@molul
Copy link

molul commented Apr 23, 2023

I confirm this is working for me now. Thanks! <3

@rtkac
Copy link

rtkac commented Apr 24, 2023

@Baboo7 thanks for the update.

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

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: export works fine

Thanks!

@Baboo7
Copy link
Owner

Baboo7 commented Apr 24, 2023

Discussion moved to #113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests