Replies: 1 comment 1 reply
-
Hey @hdodov, Thanks for reporting! I'll add that there is a 2nd situtation where a We have a roadmap item #2938 that will help the usability on the admin side for this situation. I'm going to convert this to a discussion since right now it is working as intended for now. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Link to reproduction
https://github.com/hdodov/payload/tree/bug-missing-media
To Reproduce
Describe the Bug
Services that consume the Payload API expect either an upload to exist or not. In other words, if you have a field
associatedMedia
, the value for it should either benull
or an object — withurl
,width
, etc. You don't really expect it to be a string, unless you specifydepth
and you set it to0
.There is also another case where you haven't initially specified a value for the upload, in which case the
associatedMedia
value is simply not present in the JSON. This could also cause problems.Basically there are four possibilities for the value of
associatedMedia
:undefined
(missing from the JSON) - initially, when the user hasn't specified any value for the fieldobject
- when an upload is selected by the user and can be successfully populated when a request occursstring
- when the upload has been deleted from the collection and can no longer be populatednull
- when the user has uploaded and selected a file, then removed itIt's useful to have this difference between
undefined
andnull
, and you can catch both of them with a truthy check, but thestring
situation is unexpected. If Payload attempts to populate a field from an external collection and fails to do so, it should returnnull
as the value, since that resource no longer exists.Screen.Recording.2023-07-17.at.14.35.46.mov
Payload Version
1.11.2
Beta Was this translation helpful? Give feedback.
All reactions