Skip to content

Preserve flow.json key order across load/save#218

Merged
turbolent merged 1 commit into
mainfrom
bastian/keep-order
Jun 10, 2026
Merged

Preserve flow.json key order across load/save#218
turbolent merged 1 commit into
mainfrom
bastian/keep-order

Conversation

@turbolent

Copy link
Copy Markdown
Member

Saving a flow.json (e.g. after flow dependencies install) reordered keys alphabetically because every section was a map[string]T and Go's encoding/json sorts map keys on marshal.

Ensure ordering is preserved by adding a generic orderedMap[V] that records insertion order and replays it on MarshalJSON. Every section of jsonConfig embeds it. New entries added programmatically are added at the end of their section instead of being alphabetized between existing keys.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.80292% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
config/json/ordered_map.go 55.29% 31 Missing and 7 partials ⚠️
config/json/contract.go 89.47% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@turbolent turbolent merged commit e1bcd14 into main Jun 10, 2026
2 checks passed
@turbolent turbolent deleted the bastian/keep-order branch June 10, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants