Skip to content

Servings JSON 'Day' field is always null — dead schema field #43

Description

@DTTerastar

QA finding: every row of crono-export servings --format json includes a Day field whose value is always null:

$ crono-export servings --since 90d --format json | jq '[.[] | .Day] | unique'
[
  null
]

This is documented in the prime GOTCHAS ("'servings' rows have a 'Day' field that is always null — use 'RecordedTime'"), so it's a known wart — but documenting it doesn't make it less wrong. Consumers waste a key on a sentinel; jq recipes that introspect schemas have to special-case it.

Two reasonable fixes:

  1. Drop the field from ServingRecord (json tag with omitempty or remove entirely). Cleanest.
  2. Populate it from RecordedTime's local-date portion if it's meant to be a denormalized convenience. Keeps the field but makes it useful.

I lean #1 — RecordedTime already carries the info, the GOTCHAS note already tells users to use it.

Once fixed, remove the corresponding line from cmd/prime.go GOTCHAS.

Severity: trivial (cosmetic schema cleanup)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:format--format markdown/json/csv and codec behavior.kind:bugObserved behavior diverges from documented behavior.priority:lowPolish, cosmetic, or open-ended discussion with no immediate action.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions