Skip to content

Shopping list scales a referenced recipe with servings: 0 by infinity #699

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: shopping-list


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

Summary

A referenced recipe with servings: 0 (or yield: 0) is scaled by infinity; the shopping list prints tomatoes inf with no warning.

Where

crates/core/src/shopping_list/mod.rs:1007-1026,1228-1251 — target_factor declines a zero base, then falls through to cooklang's scale_to_target, which computes target/0 = inf and returns Ok.

Repro

sauce0.cook:

---
servings: 0
---

Simmer @tomatoes{4}.

main0.cook:

Prepare @./sauce0{6%servings}.
$ cook shopping-list main0.cook
tomatoes inf

(JSON output: "value": null), exit 0, no warning — despite the UnscalableReference machinery existing for exactly this.

Expected

An unscalable-reference warning (or error); never inf.

Actual

tomatoes inf, exit 0, silent.

Acceptance criteria (red → green)

  • Red: the repro prints tomatoes inf with exit 0 and no warning.
  • Green: the repro warns that the reference cannot be scaled (the existing UnscalableReference path) and lists the ingredient unscaled or omits it explicitly.

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