Skip to content

pkg/yaml: preserve implicit null in flow mappings - #321

Open
s-johri wants to merge 1 commit into
google:mainfrom
s-johri:fix-flow-implicit-null
Open

pkg/yaml: preserve implicit null in flow mappings#321
s-johri wants to merge 1 commit into
google:mainfrom
s-johri:fix-flow-implicit-null

Conversation

@s-johri

@s-johri s-johri commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #320

An empty scalar gets flow_plain_allowed = false, so in flow style the emitter
falls back to single quoting and an implicit null becomes ''. This writes the
null explicitly instead, so a: { b: } formats to a: {b: null}. Block style is
untouched.

I used the explicit null spelling because a bare empty scalar is only safe as a
flow mapping value, and the parser rejects a: [x, , y] and a: { : 1 }. Happy
to change it if you would rather keep the original bytes.

Added a round trip test in pkg/yaml/node_test.go that decodes a document to a
Node, encodes it again, and checks the data survives.

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.

basic formatter converts an implicit null to an empty string in flow mappings

1 participant