Reviews Models and Attributes format
Informations
- Node.js version: v10.0.0
- npm version: 5.6.0
- Strapi version: 3.0.0-alpha.12.1.2
- Database: mongodb
- Operating system: Windows 10 64
What is the current behavior? After creating relation between content-types, strapi doesn't restart. Console says:
[2018-05-07T14:46:37.554Z] error Something went wrong in the model Container with the attribute contents
[2018-05-07T14:46:37.557Z] error Cannot read property 'models' of undefined
Steps to reproduce the problem Do everything in the strapi UI and always choose the defaults that strapi suggests.
Create two content types "Container" and "Content". They both have a field "Title". Add a relation to "Container": One "Container" belongs to many "Content". Then save. Strapi wants to restart. Restart will not happen. Console says:
[2018-05-07T14:46:37.554Z] error Something went wrong in the model Container with the attribute contents
[2018-05-07T14:46:37.557Z] error Cannot read property 'models' of undefined
What is the expected behavior? Strapi should restart and approve my content-types with their relation.
Suggested solutions I also did the following, which worked: I created content-type "Container", then added the relation to "Container": One "Container" belongs to many "User". I tried it because in the Content-Type-Manager when creating a relation to "User" things are displayed differently than with my own content-types. When i choose "User", then the title of the selector dropdown will also show "User (User-permissions)" but when i choose "Content" the title of the selector dropdown will just be blank. I'm not sure if it has something to do with that bug.
I tried again: Again everything was the same as described above. But then i tried to do the relation "the other way around": I added the relation to "Content": One "Container" has many "Content". It worked. And also the title of the selector dropdown will never be blank and always shows the correct content-type.
I have currently no suggestion how to solve this.
- [x] I'm sure that this feature hasn't already been referenced.
Same problem...
@dsheyp Can you try to downgrade to Node v9 and test, I don't believe any testing has been done on Node v10 and it could be whats causing this.
Hello @dsheyp I tried and it works on my side. Can you try with the last version of Strapi.
Can you share with me your 2 models please.
I updated Strapi to the latest version but as I got things working for me with the "relation the other way round" I don't want to downgrade Node - this is too much change @ the moment - I have to go on with my Strapi-based project, someone is waiting for it ;-) So I kept my current project and added the two content-types as described above. The problem persists. Strapi can't restart. I have to remove the content-types manually from the filesystem and from mongodb. Only then Strapi can restart. Still exactly the same message in the console as described.
Hi @lauriejim I put the models on https://github.com/dsheyp/strapi-models as they were created by the Content-Type-Manager
I added a Screenshot showing the dropdown title being blank.
Added: I didn't have to remove the models from mongodb. Nothing was created in mongodb by the content-type-manager. Just in the filesystem.
Exactly the same problem, the relations is created in one of ....settings.json model files but not on the second file, so I need to add this manually in the other file...
I have Node 9.11.1 and i'm experiencing the same issue so i don't think downgrading would change anything
This seems to appear at random, as I've done tests that it works fine, and others that will duplicate this exact same error. It seems to break when writing to one side of the relation.
What I discribed earlier happened again. This time I tried to manually fix the models. I had to insert a relation. It still didn't work. There was one field plugin: " " When I removed that empty field it worked. Could the reason for this bug be found in that empty plugin: " " field?
Seeing that there is problem with the plugin: " " attribute, I just want to mention that this may be related to #886. The fix is going to be released in alpha.12.2
It seems to be a duplicate of https://github.com/strapi/strapi/issues/886. It has been fixed (https://github.com/strapi/strapi/pull/1081) but not released yet.
Thanks @Aurelsicoko, So I'm waiting for 12.2 release. :wink:
@Aurelsicoko I'm having this issue in 12.2 when creating a relation.
@Aurelsicoko I also confirm that this issue still exists in 12.2. :thinking: I add some relation and my server stopped after save and not working at all. Please reopen this issue for more info.
/CC: @soupette, @lauriejim
@mnlbox & @indiecore-fm Did you try with a fresh new application ?
@lauriejim Yes, I create new app and copy my api folder in new app and then login to dashboard and create my relations.
I follow this migration guide but replace 3.0.0-alpha.11.1 by 3.0.0-alpha.12.2 https://strapi.io/documentation/migration/migration-guide-alpha-10-to-alpha-11.html
@mnlbox there is a breaking change on services code of your generated API. Please check https://github.com/strapi/strapi/wiki/migration-guide-alpha.12.1-to-alpha.12.2 for APIs migration
I tested this out as well with a fresh installation. Unfortunately, it seems that a new bug has appeared. It has a different error message from what I have experienced before.
[2018-05-25T01:51:46.804Z] error Something went wrong in the model `Testspecification` with the attribute `test`
[2018-05-25T01:51:46.807Z] error Cannot read property 'hasOwnProperty' of undefined
I'm guessing this has to do with not checking for whether the object actually exists or not, judging from Object.hasOwnProperty.
@Xcross I think it's a old issue because I see it 4 month later until now. I think Strapi need more robust code review specially about relation part of framework. It's related issues for more info: #734 #802 #886 #1081 #1143
@mnlbox the problem is, the strapi team also need to be provided with the exact ways in which to reproduce the error to help track down the cause.
@mnlbox I opened #886. The error I experienced and the issues you provided all point to this error message Cannot read property 'models' of undefined, which I believe is fixed in this current state by removing the plugin attribute. Now this different error message appeared without plugin so I think this is a new bug, unless the code behind all these is fundamentally flawed.