Problem/Motivation
The EntityFieldManager's field map is not aware of bundle fields declared in code -- this is a longstanding core bug #3045509: EntityFieldManager key/value field map gets out of sync, doesn't recognise bundle fields.
Because of this, ContentEntityDenormalizer doesn't process any bundle fields, and if incoming JSONAPI data has a value for a bundle field, it will throw an exception.
Steps to reproduce
Proposed resolution
The field map is used rather than loading field definitions because it's a more lightweight data structure, so rather than switching wholesale, fall back to checking the field definitions when the field is not found.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3522951
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
joachim commentedComment #4
catchI think this will be fixed by the MR over in #3045509: EntityFieldManager key/value field map gets out of sync, doesn't recognise bundle fields, so postponing on that issue.
Comment #6
anybody#3045509: EntityFieldManager key/value field map gets out of sync, doesn't recognise bundle fields is fixed now, wo I'm setting this back to Active.
Comment #7
catchI think we can either close this or use it to add test coverage - hopefully.
Comment #8
joachim commentedThere are already some test entity types with bundle fields -- look for FieldStorageDefinition::create in code. Not sure which is simplest to use for this.
Comment #11
mehdi.najeddine commentedOpened MR !17866 with test coverage only, as suggested in #7.
The new kernel test
ContentEntityDenormalizerTestuses the existingentity_test_comp_bund_fldentity type, as pointed out in #8. Itscomputed_bundle_fieldis defined inbundleFieldDefinitions()withFieldStorageDefinition::create().The test denormalizes a JSON:API document that sets this field. POST and PATCH both go through this denormalizer. It also checks that a bundle without the field still gets a 422 error.
The code change in MR !12055 is not needed on main.
Generated with the help of an LLM.
Comment #12
smustgrave commentedThank you for contributing but mind slowing down some please flooding our review queue with AI tickets is overwhelming