This might be a followup of #2829762: Remove wrapping "data" element from the compound docs section.
When doing a POST of the relationship of a given entity, the data array that contains the ids is skipped in here:
id_list = array_column($relationship['data'], 'id');
After chatting with @pcambra, we realized that the problem is that JSON API is not throwing an error if the relationship object is not correctly formatted.
A relationship object contains one or more resource linkage objects. Those in turn contain a resource identifier object, that states that type
and id
are both mandatory.
We should throw an error if the incoming relationship is not spec compliant.
Comment | File | Size | Author |
---|---|---|---|
#17 | string_capitalization--2831035-17.patch | 757 bytes | rajeevk |
| |||
#15 | string_capitalization--2831035-14.patch | 826 bytes | rajeevk |
#12 | string_capitalization--2831035-12.patch | 826 bytes | rajeevk |
#6 | bugfix_throw_an_error-2831035-6.patch | 804 bytes | ssemashka |
| |||
#2 | 2831035.patch | 644 bytes | pcambra |
Comments
Comment #2
pcambraComment #4
e0ipsoAfter chatting with @pcambra, we realized that the problem is that JSON API is not throwing an error if the relationship object is not correctly formatted.
A relationship object contains one or more resource linkage objects. Those in turn contain a resource identifier object, that states that
type
andid
are both mandatory.We should throw an error if the incoming relationship is not spec compliant.
Comment #5
e0ipsoComment #6
ssemashka CreditAttribution: ssemashka as a volunteer commentedI looked at the patch and it seems like it's quite outdated and cannot be applied to the latest codebase.
However, type check is already in the module based on the following code:
So, I just added id check in the patch. If it's not necessary to throw an error on empty id, I'd suggest to claim this issue as fixed if no objections.
Comment #7
e0ipsoThanks @sergesemashko. Sorry I missed you on DrupalCon, when I came back to say bye you were already gone.
Kicking testbot.
Comment #9
e0ipsoFixed.
Thank you all!
Comment #10
Wim LeersNit: s/id/ID/
Comment #11
e0ipsoComment #12
rajeevkAttaching patch with string capitalization changes as per comment.
Comment #14
e0ipso@RajeevK for some reason the patch is failing to apply. Can you re-roll it?
Comment #15
rajeevkAttaching another patch.
Comment #17
rajeevkRe-rolling patch again after created from fresh instance.
Comment #19
e0ipsoThanks @RajeevK!