Skip to content

Field names differ between renderings: -o list prints UnitCount, --jq . -o list prints unit_count #750

Closed

Description

@David-Noble-at-work

A result's field names change depending on whether an unrelated flag was passed.

$ devlore-test run -o list test_hello.star
UnitCount        : 1
ExpectationCount : 1

$ devlore-test run --jq . -o list test_hello.star
unit_count        : 1
expectation_count : 1

Same command, same result, two vocabularies.

Cause

table, csv, value, and list derive columns by reflecting over the Go value:
csvFieldName (pkg/result/delimited.go:236) reads a csv: tag and otherwise falls back to
field.Name -- the Go identifier. json and yaml honor json: tags. Nothing reconciles them.

The jq filter is the exception: JQFilter.Apply normalizes through json.Marshal first, so anything
downstream of --jq sees the tag names. That is why the flag changes the answer.

Why it matters beyond inconsistency

The json: name is what a customer sees on the Starlark surface and in every stored document. A Go
identifier is an implementation detail, and -o list was publishing it. It also breaks the naming rule
already in force: snake_case on JSON/YAML surfaces, camelCase in Go.

Fix

Make stage 1 real: normalize once at the head of Pipeline.Emit, so the filter and the formatter see the
same JSON. Documented in docs/architecture/10-command-line-interface.md §8.

Numbers must stay json.Number through normalization -- decoding to float64 rounds any integer past 2^53,
which is #712's defect.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions