Skip to content

Vitamin D rendered as 'VitaminDIU' with no unit — strippedSuffix table has 'UI' instead of 'IU' #40

Description

@DTTerastar

cmd/format.go::strippedSuffix has the suffix table:

{"Kcal", "kcal"},
{"Mg",   "mg"},
{"Ug",   "µg"},
{"UI",   "IU"},
{"G",    "g"},

But the struct field is VitaminDIU (ends in IU, not UI) — standard international-units abbreviation:

// internal/cronoapi/records.go:65
VitaminDIU       float64 \`json:"VitaminDIU"\`

So the "UI" entry never matches, and strippedSuffix("VitaminDIU") returns ("VitaminDIU", "") — markdown renders without a unit and without splitting the name. Reproduced standalone:

VitaminDIU           -> "VitaminDIU"  unit=""
VitaminAUg           -> "VitaminA"    unit="µg"
VitaminCMg           -> "VitaminC"    unit="mg"

Real-world impact: any markdown serving with non-zero vitamin D shows up as

- VitaminDIU: 123

instead of

- VitaminD: 123 IU

Fix: change the table entry to {"IU", "IU"}. (No other field ends in UI, so the old entry was dead code from the start.) Add a unit test for strippedSuffix covering one field per suffix — would have caught this on day one.

Severity: minor (cosmetic, but visible to every user with vitamin D logged)

Metadata

Metadata

Assignees

No one assigned

    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