Humanizr/Humanizer · error · InvalidOperationException

'{path}' references absent case '{caseName}'.

Error message

'{path}' references absent case '{caseName}'.

What it means

Thrown by ResolveUnit when a sameRenderedAs reference (either at the case level or the unit level) targets a case name that is not in the locale's case inventory or does not have a parsed realization. The resolver checks both inventory membership and the realizations dictionary before proceeding.

Source

Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:967

                cases[caseName] = new DurationCaseOverlay(units.ToImmutable());
            }

            return cases.ToImmutable();
        }

        static DurationCaseUnit ResolveUnit(
            string caseName,
            string unitName,
            ImmutableArray<string> inventory,
            ImmutableDictionary<string, DurationCaseRealization> realizations,
            HashSet<string> resolving,
            string path,
            bool aliasing)
        {
            if (!inventory.Contains(caseName, StringComparer.Ordinal) ||
                !realizations.TryGetValue(caseName, out var realization))
            {
                throw new InvalidOperationException(
                    $"'{path}' references absent case '{caseName}'.");
            }

            var node = $"{caseName}/{unitName}";
            if (!resolving.Add(node))
            {
                throw new InvalidOperationException(
                    $"'{path}' contains a sameRenderedAs cycle at '{node}'.");
            }

            DurationCaseUnit result;
            switch (realization.Kind)
            {
                case DurationCaseRealizationKind.Authored:
                    if (realization.Units.IsEmpty)
                    {
                        result = new DurationCaseUnit(DurationCaseUnitKind.SameAsNominative, null);
                        break;

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Check the case name in the sameRenderedAs value at the reported path against the locale's case inventory.
  2. Correct the spelling to match a case declared in the inventory, or add the referenced case to the inventory and provide its realization.
  3. Rebuild to confirm the reference resolves.

Example fix

# before
genitive:
  sameRenderedAs: genetive  # typo
# after
genitive:
  sameRenderedAs: nominative
Defensive patterns

Strategy: validation

Validate before calling

# Verify every sameRenderedAs target is in the locale's case inventory
# python: inventory = set(yaml['durationCases']['cases'].keys())
#         for case in yaml['durationCases']['realizations'].values():
#             if 'sameRenderedAs' in case: assert case['sameRenderedAs'] in inventory

Prevention

When it happens

Trigger: A unit realization or case realization uses sameRenderedAs to point to a case name that was never declared in the durationCases.cases or durationCases.inventory section, or is misspelled.

Common situations: A contributor writes sameRenderedAs: genetive (typo) instead of genitive, or references a case (e.g. 'accusative') that the locale does not actually inventory. Also occurs when a case is removed from the inventory but a sameRenderedAs reference to it is left behind.

Related errors


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/740fedd929590958. Report an issue: GitHub.