Problem/Motivation
Running drush migrate-default-content:export-migrations fails with a Symfony YAML dump exception when content includes Layout Builder overrides. The export payload contains objects (e.g., Section /
SectionComponent), which the YAML dumper refuses to serialize. This prevents migrate_default_content from generating migration YAML for content that uses Layout Builder.
Steps to reproduce
- Create a content type with Layout Builder enabled and allow overrides.
- Create a node with Layout Builder overrides (layout + components).
- Export default content (or have YAML files with layout_builder__layout data).
- Run:
drush migrate-default-content:export-migrations
Actual result
Export fails with:
Drupal\Component\Serialization\Exception\InvalidDataTypeException
Object support when dumping a YAML file has been disabled.
Stack trace points to MigrateDefaultContentCommands::writeMigrations() calling Yaml::encode() on the generated migration array.
Expected result
Export should succeed and generate migration YAML, including layout data, without attempting to serialize PHP objects.
Analysis
The migration generator currently injects a SourcePluginInterface object into the migration definition for layout fields:
'process' => [
'layout_builder__layout' => [
['plugin' => 'layout_array_to_layout_section', 'migration' => $migration],
],
],This object is not YAML-serializable. Additionally, Layout Builder values can still include Section / SectionComponent objects during export. Symfony YAML in core throws on any object.
Proposed resolution
- Normalize Layout Builder objects to arrays before YAML encoding in the export command.
- Remove the object reference from the generated migration definition (it is not used by the process plugin, which receives the Migration instance via DI).
Issue fork migrate_default_content-3569271
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
joelpittetI will let others review, but my first (hot) take is the MR might be normalizing more than it needs to solve the problem, though I have seen it fix the issue so thanks for posting @ramil g a fix!
Similar problem here #3160146: Add a Normalizer and Denormalizer to support Layout Builder and a similar issue here too #3524169: Graceful handling of serialization failures during export