processSerializedFields should handle multi-property fields

Created on 22 November 2020, over 4 years ago
Updated 2 September 2024, 8 months ago

Problem/Motivation

I'm glad to have discovered the Content Sync module, and it's working for 95% of my needs! However, for one Paragraph type including Fontawesome Icons, I get the following error when I try to import a single item:

InvalidArgumentException: Property value is unknown. in Drupal\Core\TypedData\TypedDataManager->getPropertyInstance() (line 201 of /var/www/docroot/core/lib/Drupal/Core/TypedData/TypedDataManager.php).

I've dug rather deeply into the code (having relatively recently added xdebug to my toolkit), and I know where the problem is occurring, but I don't know why it's happening. Is this a problem with Content Sync's denormailzation process, Fontawesome's configuration, or Drupal's TypedDataManager? That's where I'm stuck.

We start with Drupal\content_sync\Normalizer\ContentEntityNormalizer->denormalize() which then cycles through the Paragraph's properties via Drupal\Core\TypedData\TypedDataManager->getPropertyInstance() [source].

The Fontawesome Icon properties fall into instanceof ComplexDataInterface so we generate a $key by imploding $parts to generate something like this: entity:paragraph:unit_footer_social_media_link:field_unit_footer_facebook_icon.0:value. The "value" at the end is the $property_name we'll be looking for (and unable to find).

Since $this->prototypes[$key] is NOT set and this object is an instanceof ComplexDataInterface, we fire off $definition = $object->getDataDefinition()->getPropertyDefinition($property_name)[here] which ends up with $definition == null, thus throwing \InvalidArgumentException("Property value is unknown.") ...and as a result, the import terminates with the import page reporting "The website encountered an unexpected error. Please try again later." The above error gets logged.

The propertyDefinitions() for Drupal\fontawesome\Plugin\Field\FieldType\FontAwesomeIcon includes 'icon_name', 'style', and 'settings' but no 'value'. I've confirmed that my Content Sync yaml exports for these Paragraphs include these properties and no others.

So, we are back to the question of where this 'value' comes from that the TypedDataManager wants a property definition for. Is this something that Content Sync needs to handle differently? (Should there have been a 'value' property in the export?) Or is the Fontawesome configuation incomplete? Or is Drupal Core itself at fault?

Any help would be appreciated! I'm happy to share export config files if that would help.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States daletrexel Minnesota, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine mykola dolynskyi Poltava

    still facing

    Drupal\Component\Serialization\Exception\InvalidDataTypeException: Object support when dumping a YAML file has been disabled. in Drupal\Component\Serialization\YamlSymfony::encode()

    in 3.0-beta in context of single node export (with multivalue fields to other nodes, paragraphs and tags and nested images)

Production build 0.71.5 2024