Upgrading to 2.1.0 changes structure of `changed` attribute in JSON API

Created on 6 May 2025, 9 days ago

Problem/Motivation

After updating field_defaults, the JSON structure of the changed attribute has changed from a simple date value to a complex object with the date moved to a value key and a new preserve flag.
i.e. from

        "changed": "2023-04-14T14:58:44+00:00",

to

        "changed": {
          "value": "2023-04-14T14:58:44+00:00",
          "preserve": null
        },

This has, with no warning, broken external JSON API consumers expecting the prior structure, and the prior version of the module without this breaking change has been flagged as unsupported.

Steps to reproduce

View an entity in JSON API with field_defaults uninstalled or at version 2.0.0 or lower
View the same entity with field_defaults 2.1.0
Observe that the structure of the changed attribute has changed.

Proposed resolution

I think I understand what the preserve value is trying to do, but I don't think including it in JSON API output is valuable. Is there perhaps a way to accomplish the same thing without altering core functionality?

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States alieffring

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

Comments & Activities

  • Issue created by @alieffring
  • πŸ‡¨πŸ‡¦Canada b_sharpe

    @alieffring This property technically will be going away with dropping D10 support; however, I would think this is more something you should be aware could change from any contrib module that alters a base definition (albeit this one sucks as it went from one property to multiple which JSON API auto changes to an array)

    If you're already on D11, you can likely just comment out/remove this hook: git.drupalcode.org/project/field_defaults/-/blob/2.1.x/field_defaults.module?ref_type=heads#L16

    I've flagged 2.0.0 as supported in the meantime so D10 people have an option to stay.

  • πŸ‡©πŸ‡ͺGermany osopolar πŸ‡©πŸ‡ͺ GER 🌐

    We had the same issue with our consumer. To understand this right, we may stay on 2.0.0 or modify our consumers, but there is no way / no intention to modify the behavior, right?

  • πŸ‡¨πŸ‡¦Canada b_sharpe

    @osopolar, the intention is to remove D10 support which will allow removing this property as in D11 we can use isSyncing() per πŸ“Œ Allow ChangedItem to skip updating the entity's "changed" timestamp when synchronizing Fixed

    If you're on D10, just stick with 2.0.0 for now if you don't need this property.

Production build 0.71.5 2024