Problem/Motivation

During Recipe installation, certain configuration entities like versioned content templates or newly created fields may cause errors:

  • \LogicException when updating entities from storage records for versioned configs.
  • FieldExceptions due to stale cached field definitions when field storages or instances
    are created in the same installation loop.

Proposed resolution

  • Wrap updateFromStorageRecord() in a try/catch block to skip entities
    that cannot be updated, avoiding failures for versioned config entities.
  • Clear cached field definitions after saving field-related config entities
    (field_storage_config or field_config) to ensure subsequent
    field entities can be created without errors.
  • In FieldConfig, add a fallback to reload field storage definitions
    from config storage when cached definitions are stale, handling timing issues
    during Recipe installation.

These changes ensure that Recipe installations create fields safely and avoid exceptions caused by caching or versioned configuration conflicts.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3581250

Command icon 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

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Status: Active » Needs review
phenaproxima’s picture

Status: Needs review » Postponed

I think we should won't-fix this, for two reasons that are the same reason:

\LogicException when updating entities from storage records for versioned configs.

This is caused by Canvas bugginess. (Versioned config is not a thing in core, at least not yet; to my knowledge, Canvas invented the concept.)

FieldExceptions due to stale cached field definitions when field storages or instances
are created in the same installation loop.

This is also caused by Canvas bugginess (and should be hotfixed as of v1.3.2).

Changing core to get past bugs in Canvas is probably not a road we should go down.

It's true that Canvas does a number of questionable, yet seemingly necessary, things that break recipe application in certain circumstances. But the solution is to fix Canvas.

I don't doubt there are also some buggy conditions in core which are contributing to the overall jankiness, but they seem to generally be due to recipes not consistently setting config syncing flags (and other systemic issues). Adding try-catch blocks around specific exception conditions is fixing symptoms without curing the disease. I'd rather cure the disease, and I bet you would too. :)

rajab natshah’s picture

Got that.
Testing with Drupal Canvas 1.3.2
Moving the fix to Canvas if still needed.