Closed (fixed)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Dec 2017 at 14:15 UTC
Updated:
18 Mar 2018 at 11:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
harrrrrrr commentedComment #3
wim leersWhat would be super helpful, is a failing test which reproduces this problem :)
Comment #4
harrrrrrr commentedThis patch provides a better solution by returning an empty data [] instead of an error.
If someone wants to add a test, any relationship call with an empty non multi value reference field will cause a failure without this patch.
fi: /jsonapi/node/article/[UUID]/field_image
Comment #5
gabesulliceI've confirmed this bug exists locally. I'll write some tests for this as part of #2945093: Comprehensive JSON API integration test coverage phase 3: test JSON API-specific use cases: related/relationship routes, includes and sparse field sets.
I can't believe this has existed for so long without being noticed. Great catch @harrrrrrr!
Comment #6
wim leers👍 — thank you, @harrrrrrr! (Also: great nickname :D)
Comment #7
wim leersComment #8
gabesulliceAssigning to myself so I don't forget about this.
Comment #9
gabesulliceThis again came up while working on tests in #2945093: Comprehensive JSON API integration test coverage phase 3: test JSON API-specific use cases: related/relationship routes, includes and sparse field sets
Which led me to #2940339: Port reference field support for non-empty entity reference fields not pointing to an entity from #2543726
Which clearly is related to this issue given this line of the IS: "Function getRelated() in EntityResource.php not working when related entity field is empty becasue $field_list->entity is null."
I'm not sure if one is a duplicate of the other yet, so leaving both open. This one is for "related" routes and the other is presumably focused on "individual" routes.
The good new is that test coverage does exist now, albeit indirectly :) I'll test this patch against it shortly.
Comment #10
wim leers👍 — they indeed seem related and potentially even duplicates!
Comment #11
wim leersSee #2940342-39: Cacheability metadata on an entity fields' properties is lost.
Comment #12
wim leersI was mistaken in #11: that is a different problem: that's about a relationship being omitted from
data.relationshipscompletely when it doesn't refer to another resource.And interestingly, the bug reported here was fixed on February 14 in #2939722: Do not provide routes for internal resource types. Perhaps unsurprisingly, the changes suggested in the patch in #4 no longer apply because that code has been removed altogether!
That makes this effectively a duplicate that has already been fixed! :)
Comment #13
wim leersI found this through
git bisectand … deceivinggitbtw :DI found that
8.x-1.7worked as described in the IS. But HEAD didn't. Tellinggit bisectthat HEAD wasgoodand 1.7 wasbadwouldn't work though (because that leads git to conclude that things are good in HEAD, hence no bisecting necessary). So, just flippinggoodandbadallowed me to usegit bisectafter all :)Comment #14
wim leers@gabesullice kindly pointed out that I was severely mistaken, because I was testing
http://d8/jsonapi/node/article/c32bef09-21f5-4b63-a51f-29d0734edc3c/relationships/field_imageinstead ofhttp://d8/jsonapi/node/article/c32bef09-21f5-4b63-a51f-29d0734edc3c/field_image…Comment #15
wim leersTo not have this be blocked on #2945093: Comprehensive JSON API integration test coverage phase 3: test JSON API-specific use cases: related/relationship routes, includes and sparse field sets, here's test coverage added to
JsonApiFunctionalTest.The test-only patch is also the interdiff.
Comment #16
wim leers#2940339: Port reference field support for non-empty entity reference fields not pointing to an entity from #2543726 is for a different problem: the fact that core REST says
{target_id: null}, but JSON API just says{data: []}. Removing that from the related issues.Comment #18
gabesulliceComment #20
wim leersThis is now the only remaining blocker for #2945093-37: Comprehensive JSON API integration test coverage phase 3: test JSON API-specific use cases: related/relationship routes, includes and sparse field sets.
Comment #21
e0ipsoThis looks good to me. Thanks everyone! Merging.
Comment #23
wim leers🎉