Skip to content

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.

interface Warning {
  code: WarningCode;
  message: string;       // human-readable, ready to display as-is
  item?: string;
  loc?: { start: number; end: number }; // character offsets into the source, when available
  section?: string | null;
  data?: Record<string, unknown>; // since 1.5.0: what a tool needs to fix it (see below)
}

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.

type WarningSeverity = "error" | "warning" | "info";
const warningSeverity: Record<WarningCode, WarningSeverity>;

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.

CodeSeverityMessage template
VARIABLE_NOT_FOUNDwarningCannot resolve relative quantity: target intermediate '&{targetName}' is not defined.
RELATIVE_QUANTITY_UNRESOLVEDwarningCannot resolve relative quantity: target ingredient '@{targetName}' was not found in the current section.
RELATIVE_QUANTITY_UNKNOWN_MASSwarningCannot compute the amount of '{item}': undefined
CIRCULAR_REFERENCEerrorCircular reference detected: '{name}' depends on itself.
UNDEFINED_REFERENCEerrorUndefined reference '{prefix}{name}' — no prior step or section produces this item.
MISSING_UNITwarning{type} requires an explicit unit (e.g. min, s, °C).
INVALID_UNITwarningInvalid unit "{value}" for {type}.
SCOPE_CONFLICTerrorIntermediate variable '&{varName}' is redefined; variable names must be unique across the recipe.
MISSING_INGREDIENTwarningIngredient "{id}" not found in database — nutritional metrics and density conversions unavailable.
MISSING_MACROSinfoIngredient "{id}" has no macronutrient data in database — nutritional totals are partial.
UNKNOWN_MASSinfoCannot calculate mass for "{id}" — omitted from nutritional totals.
INVALID_MODIFIER_COMBINATIONwarningIncompatible modifiers on "{item}": {combination}.
COMPOSITE_PARENT_CONFLICTerrorComposite 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_REFERENCEwarning'{item}' cannot be used as the Baker's percentage reference (*).
NO_BAKERS_REFERENCEwarningBaker's percentages (%) are used but no base flour (*) was designated.
MULTIPLE_BAKERS_PERCENTAGEwarning'{item}' is also marked as the baker's percentage base (*), but '{reference}' already is: only one ingredient can be. '{reference}' stays the base.
TIME_PARADOXwarningTimeline conflict: {cause} is pulled earlier than recipe start to satisfy {conflict}.
TRACK_CONTENTIONinfoResource contention on track '{trackName}': delayed by {delay} min for '{item}'.
DAY_OVERFLOWwarningWorking 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_COOKWAREinfoTwo 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_RANGEwarningTimer "{item}" is longer than 1000 years, the longest duration Gram plans with: it was capped at 1000 years.
AMBIGUOUS_NUMBERwarning"{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_DURATIONwarningTimer duration "{value}" on "{item}" is not read: {reason} It is not counted in the total time.
INVALID_QUANTITYwarningQuantity "{value}" of "{item}" is not read: {reason} Did you mean {{suggestion}}? It is not counted in the shopping list or the nutrition.
OZ_AFTER_VOLUMEinfo"{value}" of "{item}" is a weight: oz weighs, {suggestion} measures a volume. Write {suggestion} if a volume is meant.
MODULE_NOT_FOUNDerrorModule "{specifier}" could not be found or resolved.
MODULE_PARSE_ERRORerrorSyntax error in imported module "{specifier}": {parseMessage}
MODULE_CYCLEerrorCircular module import detected: {chain}.
MODULE_DEPTH_EXCEEDEDerrorImport depth limit exceeded ({depth}) while importing "{specifier}".
MODULE_EXPORT_NOT_FOUNDerrorModule "{specifier}" does not export '&{exported}' — it exists in the module but isn't re-exported. Add '-> &{exported}' to the section that produces it.
UNUSED_IMPORTwarningUnused import '&{local}' from "{specifier}".
UNRESOLVED_MODULE_YIELDerrorCannot compute yield for '&{binding}' from "{specifier}": missing physical mass data for one or more ingredients.
ESTIMATED_MODULE_YIELDwarningYield of '&{binding}' from "{specifier}" is estimated using standard ingredient densities or unit weights. Scale factor is approximate.
MODULE_UNIT_MISMATCHerrorUnit mismatch for '&{binding}' from "{specifier}": requested in '{requestedUnit}' but yields in '{yieldUnit}' without a conversion density.
MODULE_BATCH_INTERPRETATIONinfo'&{binding}' from "{specifier}" requested without unit — scaled as {batches} batch(es) of the module.
IMPORTED_BAKERS_REFERENCE_DROPPEDinfoBaker's percentage base (*) from "{specifier}" is scoped to its own module and was not imported.
DENSITY_OVERRIDE_SHADOWEDinfoDensity for "{ingredient}" in host recipe ({hostValue}) overrides module "{specifier}" ({moduleValue}).
MODULE_SURPLUSinfoScaling "{specifier}" for '&{binding}' yields a surplus: {surplus}.
MODULE_SPECIFIER_INVALIDerrorInvalid module path "{specifier}": {reason}
MODULE_SCHEME_UNSUPPORTEDerrorUnsupported URL scheme in module specifier: "{specifier}".
STOCKED_RETRO_PLANNING_IGNOREDwarningStocked module "{specifier}" has a retro-planning offset "~{...}", which is ignored because stocked items require no prep time.
RETRO_PLANNING_OVERRIDE_SHADOWEDinfoHost retro-planning offset on "@use {specifier}" overrides the module's internal offset.
MODULE_BINDING_SHADOWS_INGREDIENTwarningImported binding '&{binding}' from "{specifier}" shares name with a database ingredient.
STOCKED_DESTRUCTURED_NUTRITION_BLENDEDinfoStocked module "{specifier}" uses destructured imports — nutrition profile is averaged across the entire module.

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.

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.

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 slices against cloves), a weight against a named piece, or trailing words (100 g of).
  • missingDensity / missingUnitWeight: converting between weight and volume or pieces requires density or unit_weight in 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}).

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.

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.

A Timer or Temperature was written without an explicit unit (e.g. ~{10} instead of ~{10 min}). Fix: add an explicit unit.

Emitted in three situations:

  • Time or temperature units: a word after a number in a Timer or section anchor is not a recognized time unit (~{3 bananas}), or a Temperature uses a unit other than Celsius or Fahrenheit. Fix: use a recognized time unit (h, hr, min, heures…), or °C / °F for 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}), where cup 5 tbsp would otherwise be treated as one unknown unit with no mass. Fix: write it as a sum (@flour{1 cup + 5 tbsp}); data.suggestion provides 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.
v1.5.0

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:

reasonExampleFix
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.

v1.5.0

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).

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.

v1.5.0

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.

v1.5.0

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} (≥ 60 after 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 its raw string.
  • 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.

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.

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.

The ingredient exists in the database, but its entry has no nutrition block. Fix: add a nutrition block to that database entry.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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).

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.