TypeError: Cannot read properties of undefined (reading 'label')
Whenever I go to specific Versions documents I get this error. I'm unsure as to exactly what causes the error because the Admin UI goes completely blank whenever I get it. It only happens on certain versions of documents. I've solved similar problems in validation functions that usually require adding a missing question mark (
) but am unsure of exactly where the error is coming from or what causes it so I'm not sure how to provide more context. Could this be because of a validation function or something I have written? Or is it a Payload issue? I would assume it's a Payload issue because it's in a document's Versions which I haven't messed with besides enabling them.
Included in the pictures is an example of a Version document that's breaking when I try to view it in the Admin UI. If there's any other information I can provide please let me know!
Hi @TheDunco - what version of payload are you on? we will try to replicate this
Hi! I've been experiencing this since Payload ^1.5 and am still experiencing it on v1.6.11 which is the version I'm currently running
@TheDunco this is in production, right? Any way to replicate this issue in development so that the error message is more helpful?
Alternatively, you could click on the top line in your error message to see where the error is coming from within the compiled code
Ah yes, sorry, my original message contained what it looked like in development...
@dribbens something to look into here probably regarding
probably a case of having bad data, BUT, we should be able to make that function "safer" so that it won't crash
I was thinking the same.
I'll take a 👀 . Might have trouble without steps to reproduce.
It seems to me like adding optional chaining and/or ternaries to wherever the
is accessed in that file should solve my particular issue. Is there a way to build and use the Payload dep locally so I could try this out myself?
Otherwise improving the safety of that function overall should fix the issue, but if it would help to narrow it down since I can't provide steps to reproduce I'm willing to try that
yes, you just need a local Mongo running. from there, just pull down Payload and run
yarn dev versions
to get a versions test environment set up
but you can run
yarn dev [any-test-folder]
and develop against a lot of stuff. in this case,
is the move for you i'd expect
Sweet, thanks! I was just checking and I'm actually having trouble reproducing myself, but this is an issue I've seen all over the place. Just kinda hard to nail down. I checked the document that was previously causing issues and it doesn't seem to be an issue anymore, although there seem to be less versions now than before when it was causing issues 🤷
This is in production and I have multiple designers working on it so someone else probably messed with it and fixed it unwittingly
I thought I found where this could be happening but after some testing I couldn't reproduce it.
Oh nvm, I think I know
I believe it is because this function could return null from a
not working if options have changed on the collection config.
This file could be cleaned up, looks like I got kind of wild on it.
I can sort this out, but not right now.
Cool, thanks for looking into this! It's not super urgent, just thought I'd report!
Awesome, thank you!
I'm glad you were able to figure out that it was related to changing options in select fields, that's definitely what broke things for me