Skip to content

Emit a valid YAML stream from logs -o yaml - #56

Open
puncsky wants to merge 1 commit into
render-oss:mainfrom
puncsky:fix/logs-yaml-stream
Open

puncsky wants to merge 1 commit into
render-oss:mainfrom
puncsky:fix/logs-yaml-stream

Conversation

@puncsky

@puncsky puncsky commented Oct 10, 2026 •

Copy link
Copy Markdown

Summary

render logs -o yaml marshalled each entry with its own yaml.Marshal call and wrote them back to back. Two or more entries therefore produced a single mapping with duplicate keys:

id: a
message: first
id: b
message: second

Strict parsers reject this; permissive parsers silently keep only the last entry, so automation gets an incomplete result while the command exits 0.

nonInteractiveLogs now writes every entry — listed history and tailed events — through one logWriter whose lazily created yaml.Encoder emits a ----separated multi-document stream. Zero entries still produce no output, each Encode flushes its document so --tail keeps streaming, and JSON and text output are unchanged.

Motivation

Exporting logs as YAML for scripting returned unparseable output whenever the query matched more than one line.

How to verify

  • go test ./cmd -run TestLogs — new cmd/logs_output_test.go uses the fake Render API server:
    • a two-entry list decodes strictly (KnownFields) as two documents, in order, with matching ids, messages and timestamps;
    • an empty result stays empty;
    • a tailed stream also decodes as two documents;
    • JSON and text output are byte-for-byte unchanged.
  • The two YAML stream tests fail on main.
  • Full go test ./... passes except e2e/TestE2E, which fails identically on main without credentials.

Release notes

`render logs -o yaml` now prints one YAML document per log entry, so multi-entry output parses correctly.

Each log entry was marshalled with its own yaml.Marshal call and written
back to back, so two or more entries produced one mapping with duplicate
keys. Strict parsers reject that output, and permissive ones silently keep
only the last entry.

nonInteractiveLogs now writes every entry - listed history and tailed events
alike - through one logWriter whose lazily created yaml.Encoder emits a
`---`-separated multi-document stream. Zero entries still produce no output,
each Encode flushes its document so tailing stays streaming, and JSON and
text output are unchanged.
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