Skip to content

fix(formatter): handle nil JSON values - #14153

Open
zloglevel wants to merge 1 commit into
docker:mainfrom
zloglevel:fix/formatter-nil-json
Open

fix(formatter): handle nil JSON values#14153
zloglevel wants to merge 1 commit into
docker:mainfrom
zloglevel:fix/formatter-nil-json

Conversation

@zloglevel

Copy link
Copy Markdown

What I did

Prevent formatter.Print from panicking when JSON output receives an untyped nil value. reflect.TypeOf(nil) returns nil, so calling Kind() on it panics; reflect.ValueOf(nil).Kind() safely returns Invalid and lets the existing standard JSON path emit null.

Added regression coverage for both json and legacy {{json .}} formatting. Both should produce null\n.

Related issue

No issue; this is a small, self-contained nil-input fix.

(not mandatory) A picture of a cute animal, if possible in relation to what you did

0502d80a9e7cd8cff98f188e59b65b13

Signed-off-by: zloglevel <loglevel@outlook.com>
@zloglevel
zloglevel requested review from a team as code owners August 29, 2026 18:24
@zloglevel
zloglevel requested review from glours and ndeloof August 29, 2026 18:24
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.

1 participant