Skip to content

pantry add and update persist unvalidated quantity/expire/bought/low values #710

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: pantry


Discovery audit finding M13 (medium) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified.

Summary

cook pantry add/update persist unvalidated --quantity/--expire/--bought/--low values.

Where

src/pantry.rs:782-799 (run_add), :816-844 (run_update) — strings passed straight to core, written verbatim.

Repro

$ cook pantry add dairy milk --quantity garbage
(exit 0)
$ cat config/pantry.conf
milk = "garbage"

--expire 32/13/2025 likewise. Downstream: cook sl then fails to subtract milk, cook doctor pantry still claims it "will be excluded from shopping lists", pantry expiring silently ignores the bad date.

Expected

Invalid quantities/dates are rejected with an error; nothing is written.

Actual

Garbage is persisted verbatim; exit 0.

Acceptance criteria (red → green)

  • Red: after the repro, pantry.conf contains milk = "garbage".
  • Green: the repro errors, exits nonzero, and pantry.conf is unchanged.

Verification

Executed repro.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions