Warnings
A malformed or incomplete recipe still compiles — the compiler and analyzer collect structured Warning objects instead of throwing, so callers can render a recipe and surface what’s wrong at the same time. WarningCode and friends are exported from @gram-lang/kitchen.
The Warning interface
Section titled “The Warning interface”compile() returns them on CompilationResult.warnings; analyze() carries those through and may push additional ones onto the same array on AnalyzedCompilationResult.warnings. Never a bare string — .message is always present.
v1.5.0 Certain codes also attach structured data so tools and language-server quick fixes can act without parsing .message. Only INVALID_QUANTITY ({ reason, suggestion? }), OZ_AFTER_VOLUME ({ suggestion }), and ingredient INVALID_UNIT ({ reason, suggestion? }) populate data.
Severity & --strict
Section titled “Severity & --strict”Structural integrity issues — a reference to something that doesn’t exist, a naming collision, or an unresolvable module — are error. Recoverable gaps (estimation gaps, incomplete annotations) are warning, and contextual notifications (surplus quantities, batch scaling, resource contention) are info. This is exactly the distinction the CLI’s gram check --strict flag uses: without --strict, only error-severity codes fail the command; with it, every warning and info is promoted to error too. Build your own strict-mode logic on warningSeverity[code] the same way.
| Code | Severity | Message template |
|---|---|---|
VARIABLE_NOT_FOUND | warning | Cannot resolve relative quantity: target intermediate '&{targetName}' is not defined. |
RELATIVE_QUANTITY_UNRESOLVED | warning | Cannot resolve relative quantity: target ingredient '@{targetName}' was not found in the current section. |
RELATIVE_QUANTITY_UNKNOWN_MASS | warning | Cannot compute the amount of '{item}': undefined |
CIRCULAR_REFERENCE | error | Circular reference detected: '{name}' depends on itself. |
UNDEFINED_REFERENCE | error | Undefined reference '{prefix}{name}' — no prior step or section produces this item. |
MISSING_UNIT | warning | {type} requires an explicit unit (e.g. min, s, °C). |
INVALID_UNIT | warning | Invalid unit "{value}" for {type}. |
SCOPE_CONFLICT | error | Intermediate variable '&{varName}' is redefined; variable names must be unique across the recipe. |
MISSING_INGREDIENT | warning | Ingredient "{id}" not found in database — nutritional metrics and density conversions unavailable. |
MISSING_MACROS | info | Ingredient "{id}" has no macronutrient data in database — nutritional totals are partial. |
UNKNOWN_MASS | info | Cannot calculate mass for "{id}" — omitted from nutritional totals. |
INVALID_MODIFIER_COMBINATION | warning | Incompatible modifiers on "{item}": {combination}. |
COMPOSITE_PARENT_CONFLICT | error | Composite child "{childName}" was already linked to parent "{previousParent}" — using it with a different parent "{newParent}" here means both will share the same database entry, which is very likely wrong. |
INVALID_BAKERS_REFERENCE | warning | '{item}' cannot be used as the Baker's percentage reference (*). |
NO_BAKERS_REFERENCE | warning | Baker's percentages (%) are used but no base flour (*) was designated. |
MULTIPLE_BAKERS_PERCENTAGE | warning | '{item}' is also marked as the baker's percentage base (*), but '{reference}' already is: only one ingredient can be. '{reference}' stays the base. |
TIME_PARADOX | warning | Timeline conflict: {cause} is pulled earlier than recipe start to satisfy {conflict}. |
TRACK_CONTENTION | info | Resource contention on track '{trackName}': delayed by {delay} min for '{item}'. |
DAY_OVERFLOW | warning | Working day {day} (from section '{section}') starts NaN h before its 24 h window opens: a long rest pushes it back. Anchor the section further back, for example ~{-{day}1d}, or shorten the rest. |
PASSIVE_OVERLAP_SAME_COOKWARE | info | Two passive timers overlap and both use #{cookware}: {item} and {other}. If one is meant to follow the other, give them the same named track, for example ~_{cookware}{…}, so they take turns. |
DURATION_OUT_OF_RANGE | warning | Timer "{item}" is longer than 1000 years, the longest duration Gram plans with: it was capped at 1000 years. |
AMBIGUOUS_NUMBER | warning | "{value}" on "{item}" was read as {read}: Gram reads a comma between two digits as a decimal and has no thousands separator. Write {suggestion} if that is the number you meant. |
INVALID_DURATION | warning | Timer duration "{value}" on "{item}" is not read: {reason} It is not counted in the total time. |
INVALID_QUANTITY | warning | Quantity "{value}" of "{item}" is not read: {reason} Did you mean {{suggestion}}? It is not counted in the shopping list or the nutrition. |
OZ_AFTER_VOLUME | info | "{value}" of "{item}" is a weight: oz weighs, {suggestion} measures a volume. Write {suggestion} if a volume is meant. |
MODULE_NOT_FOUND | error | Module "{specifier}" could not be found or resolved. |
MODULE_PARSE_ERROR | error | Syntax error in imported module "{specifier}": {parseMessage} |
MODULE_CYCLE | error | Circular module import detected: {chain}. |
MODULE_DEPTH_EXCEEDED | error | Import depth limit exceeded ({depth}) while importing "{specifier}". |
MODULE_EXPORT_NOT_FOUND | error | Module "{specifier}" does not export '&{exported}' — it exists in the module but isn't re-exported. Add '-> &{exported}' to the section that produces it. |
UNUSED_IMPORT | warning | Unused import '&{local}' from "{specifier}". |
UNRESOLVED_MODULE_YIELD | error | Cannot compute yield for '&{binding}' from "{specifier}": missing physical mass data for one or more ingredients. |
ESTIMATED_MODULE_YIELD | warning | Yield of '&{binding}' from "{specifier}" is estimated using standard ingredient densities or unit weights. Scale factor is approximate. |
MODULE_UNIT_MISMATCH | error | Unit mismatch for '&{binding}' from "{specifier}": requested in '{requestedUnit}' but yields in '{yieldUnit}' without a conversion density. |
MODULE_BATCH_INTERPRETATION | info | '&{binding}' from "{specifier}" requested without unit — scaled as {batches} batch(es) of the module. |
IMPORTED_BAKERS_REFERENCE_DROPPED | info | Baker's percentage base (*) from "{specifier}" is scoped to its own module and was not imported. |
DENSITY_OVERRIDE_SHADOWED | info | Density for "{ingredient}" in host recipe ({hostValue}) overrides module "{specifier}" ({moduleValue}). |
MODULE_SURPLUS | info | Scaling "{specifier}" for '&{binding}' yields a surplus: {surplus}. |
MODULE_SPECIFIER_INVALID | error | Invalid module path "{specifier}": {reason} |
MODULE_SCHEME_UNSUPPORTED | error | Unsupported URL scheme in module specifier: "{specifier}". |
STOCKED_RETRO_PLANNING_IGNORED | warning | Stocked module "{specifier}" has a retro-planning offset "~{...}", which is ignored because stocked items require no prep time. |
RETRO_PLANNING_OVERRIDE_SHADOWED | info | Host retro-planning offset on "@use {specifier}" overrides the module's internal offset. |
MODULE_BINDING_SHADOWS_INGREDIENT | warning | Imported binding '&{binding}' from "{specifier}" shares name with a database ingredient. |
STOCKED_DESTRUCTURED_NUTRITION_BLENDED | info | Stocked module "{specifier}" uses destructured imports — nutrition profile is averaged across the entire module. |
VARIABLE_NOT_FOUND
Section titled “VARIABLE_NOT_FOUND”A relative quantity references an intermediate variable (50% of &name) that hasn’t been declared as an intermediate output (->&name) anywhere in the recipe. Fix: declare the variable before referencing it, or check for a typo in the name.
RELATIVE_QUANTITY_UNRESOLVED
Section titled “RELATIVE_QUANTITY_UNRESOLVED”A relative quantity references an ingredient (50% of @name) that hasn’t appeared earlier in the same section — relative-to-ingredient targets are section-scoped, unlike variables. Fix: move the referenced ingredient earlier in the same section, or reference a variable (&name) instead if it’s meant to be recipe-wide.
RELATIVE_QUANTITY_UNKNOWN_MASS
Section titled “RELATIVE_QUANTITY_UNKNOWN_MASS”Pushed during analysis: the target of a relative quantity was found, but its own mass couldn’t be computed (no resolvable unit/density), so the percentage can’t be applied. Fix: give the target ingredient a standardizable unit, or a density/unit_weight entry in the ingredient database.
For a ratio with units (1 / 100 g @&flour, ~{15 min / 500 g @&roast}, v1.5.0), it includes a reason pointing to the ratio and leaves the amount unresolved:
noTargetQuantity: the target has no quantity.incompatibleUnits: mismatched counts (2 slicesagainst cloves), a weight against a named piece, or trailing words (100 g of).missingDensity/missingUnitWeight: converting between weight and volume or pieces requiresdensityorunit_weightin the database.wholeUseAmbiguous/producerMassUnknown: for an intermediate used whole (&dough), either another section also consumes it or the producing section’s mass is incomplete.stepProducer: the intermediate used whole is made by a step (Mix … ->&dough), not by a whole section, and only a section’s mass is weighed. Write the amount used (&dough{500 g}), or make it in its own section.
Fix: match the target’s unit, add density or unit_weight to the database, or specify the intermediate’s used quantity (&dough{500 g}).
CIRCULAR_REFERENCE
Section titled “CIRCULAR_REFERENCE”An ingredient’s relative quantity targets itself (@flour{50% of @flour}). Fix: remove the self-reference — a percentage-based quantity must target a different ingredient or variable.
UNDEFINED_REFERENCE
Section titled “UNDEFINED_REFERENCE”A bare reference (&name) or a referenceable ingredient (@&name) points to something that was never registered earlier in the recipe. Fix: introduce the ingredient (without &) before referencing it, or check for a typo.
MISSING_UNIT
Section titled “MISSING_UNIT”A Timer or Temperature was written without an explicit unit (e.g. ~{10} instead of ~{10 min}). Fix: add an explicit unit.
INVALID_UNIT
Section titled “INVALID_UNIT”Emitted in three situations:
- Time or temperature units: a word after a number in a
Timeror section anchor is not a recognized time unit (~{3 bananas}), or aTemperatureuses a unit other than Celsius or Fahrenheit. Fix: use a recognized time unit (h,hr,min,heures…), or°C/°Ffor temperatures. - Unjoined quantities in a unit v1.5.0: an ingredient’s unit looks like two quantities without an operator (
@flour{1 cup 5 tbsp}or@flour{1 kg 200 g}), wherecup 5 tbspwould otherwise be treated as one unknown unit with no mass. Fix: write it as a sum (@flour{1 cup + 5 tbsp});data.suggestionprovides the corrected unit (cup + 5 tbsp) for editor quick fixes. Descriptive unit text like@tomatoes{1 tin of 400 g}is unaffected. - Leading prose before a number: a unit hides a leading word before the number (
@flour{about 200g}), since quantities must start with a number. Fix: write@flour{200g}and keep"about"in the prose. Pure text quantities ({a pinch},{to taste}) raise nothing.
INVALID_QUANTITY
Section titled “INVALID_QUANTITY”Emitted when a sum of quantities or number expression cannot be evaluated. The recipe still compiles and renders the text as written, but the value is excluded from shopping list and nutrition totals. data.reason identifies the cause:
reason | Example | Fix |
|---|---|---|
unitlessTerm | {1 + 1 cup} | Give every term a unit ({1 cup + 1 tbsp}). |
percentTerm | {100 g + 10%} | Write the computed total ({110 g}, provided in data.suggestion) or use a relative quantity ({10% &flour}). |
expressionTerm | {2 x 100 g + 50 g} | Sums only support + and -; write {250 g}. |
quantityInUnit | {1 tin of 400 g + 50 g} | Express the amount in a single unit ({450 g}). |
nonPositiveTotal | {1 tbsp - 1 cup} | Subtracted amount equals or exceeds what was added. |
rangeAfterMinus | {1 cup - 1-2 tbsp} | Put ranges on added terms, or write the total as a range. |
minusAcrossFamilies | {1 cup - 20 g} | Subtract only from the same unit family (volume from volume, weight from weight). |
zeroDenominator | {1/0 cup}, {1/0% &dough}, #pan{1/0}, ^{1/0 °C} | Division by zero is ignored; write a valid fraction (1/2). |
zeroRatioDenominator | {2 g / 0 g @&flour}, ~{15 min / 0 g @&roast} | A ratio per nothing is ignored; write the amount it is per (/ 100 g). |
relativeNotSupported | @eggs{3}<@box{50% @&flour}, @eggs{1}<@box{1 / 100 g @&flour} | Percentages and ratios are not supported on composite parents yet; specify the parent’s quantity (@eggs{3}<@box{1}). |
Subtraction is checked per unit family: {1 cup - 2 tbsp + 30 g} is valid (2 tbsp are subtracted from 1 cup), while {1 cup - 20 g} has no weight to subtract from.
OZ_AFTER_VOLUME
Section titled “OZ_AFTER_VOLUME”Informational notice when oz follows a volume in a sum (@water{1 cup + 2 oz}). Because oz denotes weight, Gram keeps it separate from the volume. Fix: change to fl oz if fluid ounces were intended (data.suggestion offers this quick fix).
DURATION_OUT_OF_RANGE
Section titled “DURATION_OUT_OF_RANGE”A timer or a section’s retro-planning offset lasts longer than 1000 years. Fix: check the number, often a stray digit or a missing unit letter (~{-3000d} is eight years, ~{-3000000000d} is not a recipe). The duration is capped at 1000 years, so the timeline stays finite instead of coming out as 0, Infinity or NaN. That limit is a technical bound, not a judgement on recipes: anything up to it, a solera that runs for decades included, is planned as written and raises nothing.
AMBIGUOUS_NUMBER
Section titled “AMBIGUOUS_NUMBER”A comma followed by three digits after one to three integer digits (@flour{1,000 g}, @flour{12,500 g}). Because Gram supports decimal commas and has no thousands separator, {1,000 g} is parsed as 1 g (and {12,500 g} as 12.5 g). Checked across quantities, timers, temperatures, percentages, and section anchors (including on @use). Fix: write {1000 g} if a thousand was meant, or {1 g} otherwise. Periods ({1.000 kg}) always parse as decimals without warning.
INVALID_DURATION
Section titled “INVALID_DURATION”A timer or section anchor uses numbers and units Gram recognizes, but in an ambiguous or unsupported shape:
- Ambiguous or malformed timers:
~{1:30}(hours or minutes?),~{30min 1h}(wrong order),~{1h75}(≥ 60after hours),~{1-2h30}(ambiguous range bound),~{2-1 h}(reversed range),~{2 * 2 min}, or prose (~{half an hour}). The timer is excluded from total time while keeping itsrawstring. - Unsupported anchors: ranges (
~{-1-2d}), seconds (~{-1min30},~{-5'}), or proportional anchors (reason: "anchorRatio"). - Proportional timer limits: multipliers (
~{15 min / 500 g @&roast * 2},reason: "ratioMultiplication") or ranged targets (~{15 min / 1-2 kg @&roast},reason: "ratioShape").
Fix: follow the suggested format in .message (e.g. ~{1h30}, ~{1:30 min}, ~{1h30-2h}). Unknown units after a number still raise INVALID_UNIT, and bare numbers raise MISSING_UNIT.
SCOPE_CONFLICT
Section titled “SCOPE_CONFLICT”Two sections declare the same intermediate/global variable name (->&name). Variable names must be unique across the whole recipe, not just within a section. Fix: rename one of the two declarations.
MISSING_INGREDIENT
Section titled “MISSING_INGREDIENT”During nutrition estimation, an ingredient with a computable mass has no matching entry (by id or alias) in the ingredient database at all. Fix: add the ingredient (or an alias to an existing entry) to your database.
MISSING_MACROS
Section titled “MISSING_MACROS”The ingredient exists in the database, but its entry has no nutrition block. Fix: add a nutrition block to that database entry.
UNKNOWN_MASS
Section titled “UNKNOWN_MASS”Nutrition estimation couldn’t compute a mass for this ingredient at all (unresolvable unit, no density/unit_weight), so it’s excluded from the totals. Fix: same as RELATIVE_QUANTITY_UNKNOWN_MASS — give it a standardizable unit or physical data in the database.
INVALID_MODIFIER_COMBINATION
Section titled “INVALID_MODIFIER_COMBINATION”Conflicting or duplicated modifiers on the same ingredient/cookware — e.g. optional (?) with important (*), hidden (-) with important (*), hidden (-) with referenceable (&), or the same modifier twice. The specific combination is named in .message. Fix: remove the conflicting modifier.
INVALID_BAKERS_REFERENCE
Section titled “INVALID_BAKERS_REFERENCE”The ingredient marked as the baker’s-percentage base (via the * modifier or the bakersReference option) has a mass that was itself derived from another ingredient’s relative quantity — it can’t also serve as the 100% anchor, since that would be circular. Fix: mark a different ingredient with an absolute (non-relative) quantity as the reference.
NO_BAKERS_REFERENCE
Section titled “NO_BAKERS_REFERENCE”Baker’s math was explicitly requested (enableBakersMath with a bare * search, or an explicit bakersReference id) but no ingredient matched. Fix: mark an ingredient with the * modifier, or correct the bakersReference id to match an existing ingredient.
MULTIPLE_BAKERS_PERCENTAGE
Section titled “MULTIPLE_BAKERS_PERCENTAGE”v1.5.1 More than one ingredient is marked as the baker’s-percentage base (@*flour{500 g} and @*rye{100 g}). The first one marked stays the base; the others lose their * and the rest of the recipe compiles as usual. The same ingredient marked twice is the same base and raises nothing. Fix: keep the * on a single ingredient.
COMPOSITE_PARENT_CONFLICT
Section titled “COMPOSITE_PARENT_CONFLICT”A short composite child name (e.g. @juice) is drawn from two different parent ingredients within the same recipe (e.g. <@lemon in one step and <@orange in another). Fix: use the full name for the child (e.g. @lemon juice and @orange juice) to prevent database identity collisions.
MODULE_NOT_FOUND
Section titled “MODULE_NOT_FOUND”An imported module specified in a @use directive could not be resolved or found on the filesystem. Fix: verify the module path, file extension (.gram), or configured path aliases in config.yaml.
DAY_OVERFLOW
Section titled “DAY_OVERFLOW”A working day (derived from a section’s ~{-Nd} anchor) starts before its 24-hour window opens because a long passive rest pushes it backward. Fix: anchor the section further back (for example ~{-2d} instead of ~{-1d}), or shorten the rest duration.
TIME_PARADOX
Section titled “TIME_PARADOX”During ALAP reverse scheduling, a producing task is pulled earlier than the beginning of the recipe to satisfy an intermediate consumption deadline or serving time. Gram rebases the timeline to start at zero. Fix: check whether active steps and rest intervals before the deadline fit realistically within the available timeframe.
TRACK_CONTENTION
Section titled “TRACK_CONTENTION”Multiple passive timers share the same equipment track (e.g. ~_oven) and cannot execute simultaneously. The scheduler serializes them sequentially to prevent equipment collision, delaying the second task. Fix: this is an informational notice; if you have access to multiple appliances, assign them distinct track names (e.g. ~_oven1 and ~_oven2).
PASSIVE_OVERLAP_SAME_COOKWARE
Section titled “PASSIVE_OVERLAP_SAME_COOKWARE”Two passive timers overlap in time, in steps that cite the same cookware (#oven in both), with no named track in common. If one is meant to follow the other, they are probably on one oven: the plan shows them side by side. Fix: give them the same named track (~_oven{30min} then ~_oven{20min}) so they take turns; if both fit in the oven at once, this is only an informational notice. Only names are compared (#oven with #oven), so it works whatever the language of the recipe, and the overlap is read on the default timeline.