Skip to content

Empty markdown output prints '_(no records in window)_' instead of being empty — breaks 'data only on stdout' contract #16

Description

@DTTerastar

The contract: "Empty = exit 0, empty output ([] for JSON)". The CLI honors this for JSON ([]) but for markdown emits a sentinel string on stdout:

// cmd/format.go
func emptyMsg(w io.Writer) error {
    _, err := fmt.Fprintln(w, \"_(no records in window)_\")
    return err
}

Repro:

$ /tmp/crono-export biometrics --since today --until today > /tmp/out 2>/tmp/err
$ cat /tmp/out
_(no records in window)_

This breaks scripts that pipe markdown output into something like pandoc or simply check [ -s file ] to decide whether to send the report. It's also a stdout-vs-stderr contract violation: the message is meta-information, not data, so it belongs on stderr (or simply omitted).

Expected behaviors (pick one, ideally the first):

  1. Empty result -> empty stdout (zero bytes), exit 0. (Matches the JSON branch, which prints [] only because that is the data.)
  2. If a human-readable hint is desired, print it on stderr, not stdout.

Affected callers: renderServings, renderBiometrics, renderExercises, renderNutrition, renderNotes all delegate to emptyMsg.

Severity: major

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions