Skip to content

star writes an empty list in a command's result as null #1215

Closed

Description

@David-Noble-at-work

Problem

A star command that returns an empty list prints null where the list belongs, at every depth: a result with nothing
in it prints null instead of [], and a record's empty list prints, for example, "home": null instead of
"home": []. In cmd/star/extension/result.go, goSlice starts from var out []any; a list with no elements leaves
it a nil slice, and JSON writes a nil slice as null.

Anything that loops over such a list fails. star github schedule report gives nearly every issue an empty home,
labels, assignees, blocked_by and projects, and a query like
--jq 'map(select(any(.home[]; .schedule == "s1")))' stops at the first of them: jq exits 5, "Cannot iterate over
null". A search or a filter that matches nothing makes --jq '.[]' fail the same way.

Found on 2026-11-08 by tests/Test-StarGitHub in NobleFactor/noblefactor-engprod#436's worktree: its cases for the
report's home and the sweep's lists fail on it, and nothing in the extension can work around it.

Solution, if known

A list is always a list. goSlice starts from an empty slice, make([]any, 0), so that an empty list is [] in every
rendering; a key that holds one value, and holds none, stays null. The owner ruled on 2026-11-08 that star returns an
empty list in place of null everywhere: nothing in a result uses null on a list to mean anything but none. Every star
command's output changes with it, and where an empty list printed null it prints [].

Outstanding questions

  • Whether pkg/op/starlarkbridge's converter, which turns a Starlark list into a Go value for a provider's arguments,
    makes the same nil slice of an empty list, and so whether "everywhere" reaches it too.
  • Whether a rendering other than JSON and YAML relies on an empty list being nil: csv, value, table and list
    render an empty input as no bytes today.

Evidence of completion

Plan and design documents

Kind Document
Plan docs/plans/fix/1215-empty-list-not-null.md

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