Informations
What is the current behavior?
Relation still break after 7 month. :cry: :cry: :cry: :disappointed: :disappointed: :disappointed: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: I think it's a critical issue and need to fix soon. It's break all of project with one click. :disappointed:
Related issue
Steps to reproduce the problem
ArticleTagArticle and Tag with N:N type.[2018-10-08T08:26:08.007Z] info The server is restarting
[2018-10-08T08:26:11.534Z] error Something went wrong in the model `Article` with the attribute `tags`
[2018-10-08T08:26:11.538Z] error The attribute `articles` is missing in the model Tag
What is the expected behavior?
Create N:N and 1:N relation without headache.
Suggested solutions
Fix it as you done it later in: #1490
/CC: @soupette @Aurelsicoko @lauriejim @derrickmehaffy @Pritoj
Are you using capitals in the model name @mnlbox ?
If you are still having this issue, please provide exact steps to reproduce the issue. (Ignore the old ones for now). The Strapi team can't fix an issue if they don't know how to reproduce it. (Include pictures, logs, whatever you can)
@derrickmehaffy This is old issue and related issue logs still valid. Also I provide exact steps to reproduce the issue in above post (Steps to reproduce the problem part).
Anyway I create this repo too for test:
https://github.com/mnlbox/strapi-relation-bug
Let's take a look man please. :wink:
I didn't use any capital character in model name.
I'm using Firefox and Chromium, is it related to browser?
Hmmm it seems on your tag model the relation was created:
https://github.com/mnlbox/strapi-relation-bug/blob/master/api/tag/models/Tag.settings.json
Give me a few moments and I'll try and duplicate this locally.
The error comes from the articles attribute missing in this file.
Here's how to fix it
"articles": {
"collection": "article",
"via": "tags"
}
The error comes from the
articlesattribute missing in this file.Here's how to fix it
"articles": { "collection": "article", "via": "tags" }
Yup that is what I noticed too @soupette I think he is saying the adminUI wasn't creating it, but I just tested locally and couldn't duplicate it. Strapi created both entries properly in both models.
@mnlbox I was using chrome beta (latest version) and mysql in my test but it worked fine for me. :man_shrugging:
Well the problem is that strapi doesn't write the files correctly when creating relations and this bug happens randomly or might be related to the OS.
Hmmm yeah I've never seen it unless I try using odd symbols in the model/field name. I also don't use Firefox which it seems could also be related.
@soupette It's not randomly. It's happens every time for 1:N and N:N relation on my Linux machine.
Really why it's create relation in one side and can't create on other side? :thinking:
@derrickmehaffy what is your OS?
Linux Mint 19 (Ubuntu 18.04)
Linux Mint 19 (Ubuntu 18.04)
@derrickmehaffy
:thinking: I'm also using Mint 18.3 So maybe it's not related to OS :thinking:
@soupette I add that code that you send and it's working now but after add new 1:N relation it's again break. :thinking:
I push new code also to https://github.com/mnlbox/strapi-relation-bug
See that please.
@mnlbox can you try updating to node 10 please? (Node 9 is EOL, and I want to rule out issues with node 9 to node 10)
Create a relation between Article and Tag with N:N type
Can you help me with the instructions on how to create that?. I really don't know, When I tried to create relations I don't understand the GUI :( ...
@derrickmehaffy I try to switch to node 10.0.0 with NVM but still that issue exists. :disappointed:
Really why it's happens just for me?? :cry:
I test it in 3 system with Ubuntu and Mint and anywhere server crash after restart.
@maturanomx please see this:

For more info read this docs: https://strapi.io/documentation/guides/models.html#relations
If you still have question please ask it here: https://strapi.slack.com/
@mnlbox Which browser are you using? I noticed this behaviour using Firefox, it was working well with others browsers (Chrome, Safari)...
@Aurelsicoko I have this issue in both Firefox and Chromium.
Good news I just found the issue. I'm fixing it
@soupette Really??????
yohooooooooooooooo
I really want to see the reason for this problem :thinking:
Well Firefox sends plugin: true, pluginValue: ' ' in the POST request. Where chrome doesn't
Has this issue been resolved? I ran into this exact same problem. My Strapi version is 3.0.0-alpha.14.5, and yes, I'm using Firefox.
My OS is Ubuntu 18.04.1.
@czanella Can you try with another browser?
This just occurred for me in Chrome. Here are the directories for the two content types that are causing the issue... not sure if it's related to this or to #1370 or maybe neither. I tried a second time, and it did the same thing, so I deleted the API folders... but now I have contentString and page content types stuck in the side navigation, when those content types don't exist in the Content Type Builder anymore.
[2018-12-09T00:13:11.777Z] error Something went wrong in the model `Page` with the attribute `contentStrings`
[2018-12-09T00:13:11.780Z] error Cannot read property 'attributes' of undefined
What is the version of Strapi you use please.
This Issue still exists I tried to add a one to many relation and my whole strapi server crashed. I am not able to start it again since it crashes on startup now. Is there any way for now to resolve this issue manually by editing the code?
@daehruoydeef can you provide me with your strapi version and also the steps you made in order to create your relations?
@soupette
Strapi version : v3.0.0 Beta-8
I resolved the issue by editing the settings file and completly deleting the relations now.
I got Notes and Users
I added relations like this:
User has many Notes
Note has many Users (created Table name as collectors)
Then I renamed the first relation from users to author
After I renamed the first relation to author I got the Error:
TypeError: Cannot read property 'nature' of undefined
After I resolved the Issue I was not able to recreate the bug, I feel like this was caused of the renaming of the relations. I gave correct names on the first try and it works now!
Not sure what the latest is with this, since I'm extremely new to Strapi. I've just been playing around with it on my laptop and found that adding a relationship between 2 content types (called user and address) broke my site. I saw this thread so thought I'd post the error here.
I have version 3.0.0-beta.18.3 installed and the error I got is:
[2019-12-29T23:10:44.915Z] error Something went wrong in the model `Address` with the attribute `user`
[2019-12-29T23:10:44.917Z] error TypeError: Cannot read property 'attributes' of undefined
at Object.getNature (C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi-utils\lib\models.js:150:33)
at C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi-connector-bookshelf\lib\mount-models.js:156:21
at Array.forEach (<anonymous>)
at C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi-connector-bookshelf\lib\mount-models.js:149:40
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
at async Promise.all (index 1)
at async Promise.all (index 0)
at async DatabaseManager.initialize (C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi-database\lib\database-manager.js:39:7)
at async Strapi.load (C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi\lib\Strapi.js:362:5)
at async Strapi.start (C:\_Code\no-source-control\Playing Around\strapi-quick-start\node_modules\strapi\lib\Strapi.js:196:7)
npm ERR! code ELIFECYCLE
npm ERR! Exit status 1
npm ERR!
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USERNAME\AppData\Roaming\npm-cache\_logs\2019-12-29T23_10_44_953Z-debug.log
I started creating an API with the help of Strapi due to it's GraphQL features: I added a 1:1 relationship in User and Questionnaire.
[2020-01-02T12:27:03.086Z] error Something went wrong in the model Questionnaire with the attribute user
[2020-01-02T12:27:03.089Z] error TypeError: Cannot read property 'attributes' of undefined
If it helps anyone,
I was dealing with the same issue, i had a 1:many relationship in User and Quizzes.
the quizzes.settings.json originally had this attribute
"user": {
"via": "quizzes",
"model": "user"
}
and was throwing the error. Changing the attribute to this
"user": {
"plugin": "users-permissions",
"collection": "user"
}
fixed the issue.
Why did this happen ? No idea here, these type of random errors makes my decision to use strapi in long term projects questionable at least. In any case , whatever you do in the strapi admin area should never lead to a situation like this, something is definitely missing there.
Hello! Can you tell me how you tried to create your relation? Using the Content Type Builder of by updating your Model's files?
Hello! Can you tell me how you tried to create your relation? Using the Content Type Builder of by updating your Model's files?
Simple Content type builder, this is why it seemed strange to me that something like this happened.
As soon as i saved the content-type , the server errored. Tried checking the db for incosistencies , but everything seemed normal, the only way i found to fix this was by editing the json file.
If it helps anyone,
I was dealing with the same issue, i had a 1:many relationship in User and Quizzes.
the quizzes.settings.json originally had this attribute
"user": { "via": "quizzes", "model": "user" }
and was throwing the error. Changing the attribute to this
"user": { "plugin": "users-permissions", "collection": "user" }
fixed the issue.
Why did this happen ? No idea here, these type of random errors makes my decision to use strapi in long term projects questionable at least. In any case , whatever you do in the strapi admin area should never lead to a situation like this, something is definitely missing there.
I got the same issue:
error Something went wrong in the model `Commentaire` with the attribute `user`
error TypeError: Cannot read property 'attributes' of undefined
with
"user": {
"via": "commentaires",
"model": "user"
}
I tried your solution, but then I got
error Something went wrong in the model `Commentaire` with the attribute `user`
error TypeError: Cannot read property 'toLowerCase' of undefined
any suggestion?
@lauriejim what would be the process to unlock me?
Most helpful comment
Good news I just found the issue. I'm fixing it