-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
TypeError Cannot read property 'id' of null if API response { "data": null } #6920
Comments
@jelhan this has been true for probably 2 major versions. The correct response here is to throw a 404 not-found error. |
Not saying that the API I'm fighting with is behaving correctly... 🤷♂️ But I think Ember Data should not throw a Supporting |
@jelhan in this case not returning a |
I'm not arguing that returning Having that said I'm still tending to disagree that returning a
I'm not sure if the spec is that strict. It allows to return
The spec gives an example for that case:
That example is about a relationship link but I would argue that there are also cases in which a URL for a specific combination of type and ID may "correspond to a single resource, but doesn’t currently." One example I could imagine is a blog post that isn't published yet. |
@jelhan looking at this again and totally agree we should assert here. Not sure why I was so opposed before. Thanks for surfacing! |
Related to #7547 |
If API response with
{ "data": null }
to a find request, this warning throws aTypeError
:data/packages/store/addon/-private/system/store/finders.js
Lines 53 to 59 in 637d606
payload.data
isnull
. Trying to accessid
onnull
throws.Actually it doesn't make much sense to return
{ "data": null }
by our API if the resource does not exist but it's explicitly be allowed by JSON:API spec in some cases:I'm facing this issue in Ember Data
3.14.0
but from reading changelog and inspecting the code that has triggered it, I'm quite sure it's still the same for3.16.0-beta.0
.The text was updated successfully, but these errors were encountered: