Problem/Motivation
The issue was covered by #3020112: [Regression] API change in jsonapi module., but once that was resolved, it uncovered this particular one.
The issue is once jsonapi_extras is installed unless you explicitly SAVE the resource type fields are not shown through the API.
In short the default behavior has regressed and any time that a NullResourceType is used, the particular resource in the API will not have fields present in the payload.
This is caused by code from jsonapi_extras (the early return):
/**
* ...
*/
protected function overrideFieldMapping(JsonapiResourceConfig $resource_config) {
if ($resource_config instanceof NullJsonapiResourceConfig) {
return [];
}
// ...
}
And how NULL configs handle fields...
Proposed resolution
Any direction on how to resolve this, and feedback on whether the current patch direction is ok-ish.
Except the patch, there is a semi-work-around - go in the UI and re-save all entity configs manually and export that as configurations, so we are not using the NULL configs anywhere. At that point everything will be marked as overwritten and maintenance efforts will greatly increase. This is first not a scalable option and it is not a valid one, as we can not expose web forms and similar dynamic things through JSON:API anymore.
I will propose to extend the NULL type with a valid original ID (even if it's NULL) so we can fetch field mappings for it if needed.
This is jsonapi_extras issue due to the fact it's resolved once jsonapi_extras is disabled as seein in #5.
Remaining tasks
- Direction approval.
- Resolve the API write issue in tests and/or code (TBD).
- Patch (we have API-read scenario working now)
- RTBC
- Commit
User interface changes
None.
API changes
None expected...
Data model changes
None.
Release notes snippet
None.
Comment | File | Size | Author |
---|---|---|---|
#24 | 3020237--regression--24.patch | 10.68 KB | e0ipso |
| |||
#15 | interdiff-3020237-11-15.txt | 1.04 KB | ndobromirov |
#15 | 3020237-15.patch | 2.77 KB | ndobromirov |
#8 | regression_jsonapi-3020237-8.patch | 2.21 KB | rhristov |
Comments
Comment #2
ndobromirov CreditAttribution: ndobromirov at FFW commentedComment #3
ndobromirov CreditAttribution: ndobromirov at FFW commentedComment #4
ndobromirov CreditAttribution: ndobromirov at FFW commentedWhat was the reasoning behind NULL configs?
With all the caches involved, in the process now is the speed-up from NULL configs still meaningful?
Why not just instantiate fully valid resource configurations based on system state instead of NULL instances and just have a flag that they are default.
Add a DefaultResourceConfig(entity, bundle), so upon creation, this will be handled transparently from:
Just throwing ideas... :(
Comment #5
ndobromirov CreditAttribution: ndobromirov at FFW commentedDisabling the jsonapi_extras is resolving the issue, so it's not jsonapi related.
Comment #6
ndobromirov CreditAttribution: ndobromirov at FFW commentedHere is an atempt at a fix...
Comment #8
rhristov CreditAttribution: rhristov at Bulcode commentedApplying a new patch that is fixing the issue: it fallbacks to the default JSONAPI resource type and field item normalizer if the configuration is not overridden.
Comment #9
rhristov CreditAttribution: rhristov at Bulcode commentedComment #11
ndobromirov CreditAttribution: ndobromirov at FFW commentedHandle the exception case as well in the same manner...
Comment #13
ndobromirov CreditAttribution: ndobromirov at FFW commentedI am sure that at least some of the tests are now broken and this is jsonapi 2.x related somehow. Terms
tid
is now exposed asdrupal_internal__tid
.Comment #14
ndobromirov CreditAttribution: ndobromirov at FFW commentedComment #15
ndobromirov CreditAttribution: ndobromirov at FFW commentedUpdating tests should resolve one of the failures as it seems like a change in the structure there.
Comment #17
ndobromirov CreditAttribution: ndobromirov at FFW commentedThe only failing test is write through the api.
As this is not a use case for us, we can use the patch as is.
Any support to make this green will be appreciated as I am not 100% sure how to test the writes manually :)!
Comment #18
vtcore CreditAttribution: vtcore commentedJust updated jsonapi to from 2.0-rc2 to 2.0-rc3 and exactly the same thing happened. For not overwritten resources the response is missing the
attributes
property.Another thing is that the
nid
andvid
properties are nowdrupal_internal__nid
anddrupal_internal__vid
while in the overwrites UI of JSON:API Extras they are still namednid
andvid
.Comment #19
ndobromirov CreditAttribution: ndobromirov at FFW commentedComment #20
daniel.nitsche CreditAttribution: daniel.nitsche commentedI haven't had time to test this thoroughly, but the patch in #15 seems to bring back attributes and relationships where they were previously missing.
@vtcore -- should a separate issue be logged for the nid/vid issue?
Comment #21
ndobromirov CreditAttribution: ndobromirov at FFW commentedComment #22
cspitzlayMy 2 cents:
I had similar issues: supposedly unkown filter fields (and missing fields in the output when not filtering).
I tried #15 and it solved the issue in my test cases.
Comment #23
ndobromirov CreditAttribution: ndobromirov at FFW commentedUpdated issue summary with latest findings...
Comment #24
e0ipsoComment #26
e0ipsoComment #27
Wim LeersI think #3020365: Fatal error with JSON:API 2.0-RC3 at /jsonapi/user/user: Call to a member function getPropertyType() on null was a duplicate?
Comment #28
e0ipsoGood call @Wim Leers. Thanks for this!
Comment #30
audriusb CreditAttribution: audriusb commentedI am still having an issue in v3.3. file field is always empty but it comes back populated when I disable jsonapi_extras. trying with jsonapi 2.1