Skip to content

Shopping list silently drops ingredients whose names differ only by case #694

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: shopping-list


Discovery audit finding H1 (high) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified against a debug build; baseline cargo test 1266 passed / 0 failed.

Summary

The shopping list silently drops ingredients whose names differ only by letter case. Both the CLI and the web UI are affected — a shopper under-buys.

Where

  • crates/core/src/shopping_list/mod.rs:317-326 calls IngredientList::categorize.
  • Root cause is in the cooklang 0.19.0 dependency, ingredient_list.rs categorize(): the lookup is an IndexMap keyed by name.to_lowercase(), so .collect() keeps only the last of sugar/Sugar.
  • CookCLI can fix this in AggregatedList::build (pre-merge case variants); alternatively the dependency can fix categorize.

Repro

Recipe case2.cook:

Add @sugar{1%cup} and @Sugar{2%cups}.
$ cook shopping-list case2.cook
Sugar 2 cups

The 1 cup of sugar vanishes. Same via the web UI: POST /api/shopping_list returns only Sugar.

Expected

Both entries appear on the list (sugar 1 cup and Sugar 2 cups, or an aggregated 3 cups).

Actual

Only Sugar 2 cups is listed; the 1 cup is silently dropped.

Acceptance criteria (red → green)

  • Red: the repro prints only Sugar 2 cups.
  • Green: the repro lists both case variants (or their sum); the web UI answer contains both names.

Verification

Executed repro, verified on the CLI and the web UI.

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