fix (config): deterministic JSON key ordering for config.json#944
Open
kisst wants to merge 1 commit into
Open
Conversation
The connections field ([]map[string]any) was serialized using json.Marshal which produces non-deterministic key ordering due to Go's random map iteration. This caused spurious diffs when the config file is kept under version control. Replace json.Marshal with a custom marshaler that sorts map keys before serialization, ensuring stable output across saves.
Author
|
@mickael-kerjean can you check this, I am spamming my filestash config git repo with a bunch of meaningless changes. |
Owner
|
I am head deep in some other things, I will give it a look when I have some time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connectionsfield ([]map[string]any) in config was serialized usingjson.Marshal, which produces non-deterministic key ordering due to Go's random map iteration orderconfig.jsonis kept under version control — keys would randomly reorder on every save even when no actual values changedjson.Marshalwith a custom marshaler that sorts map keys alphabetically before serialization, ensuring stable and deterministic outputTest plan