Skip to content

Config JSON key sort order changes without value changes #6939

@bennybobw

Description

@bennybobw

Description of the bug

We have an issue between my production server and my local machine where the order of JSON keys in config changes even when the value doesn't change.

Steps To Reproduce

Not sure how to reproduce exactly. I thought this might be from a php version change on my local machine (prod has 8.1.32 and my local has 8.2.38). I tested this out and switched to 8.1.32 on my local and I'm still getting the changed key order. So it's not that.

Here's an example diff though:

diff --git a/config/staging/field.bundle.node.case.json b/config/staging/field.bundle.node.case.json
index 11368d0..8954506 100644
--- a/config/staging/field.bundle.node.case.json
+++ b/config/staging/field.bundle.node.case.json
@@ -1,7 +1,7 @@
 {
     "_config_name": "field.bundle.node.case",
-    "entity_type": "node",
     "bundle": "case",
+    "entity_type": "node",
     "view_modes": {
         "teaser_block": {
             "custom_settings": true

Obivously it's fine in this case but it gets harder to tell if something has actually changed when bigger chunks are out of order. I assume we could sort all the keys alphabetically. The only thing I wonder about that is whether that will annoy module developers who have put their keys in a specific order for scan-ability. I assume most people aren't inspecting these configs visually though and to avoid these kind of diff issues I'd think it would be worth it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions