Humanizr/Humanizer · error · InvalidOperationException

Case-aware citation phrases for '{catalog.LocaleCode}' requi

Error message

Case-aware citation phrases for '{catalog.LocaleCode}' require '{path}'.

What it means

Thrown by ValidateCitationBaseDurationForms when the 'phrases' section exists but lacks a 'duration' sub-mapping. The path variable is constructed as {localeCode}.phrases.duration and the validator confirms the 'duration' key is present before iterating time units.

Source

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

            DurationCaseCatalog catalog,
            SimpleYamlValue? phrasesValue,
            ImmutableArray<string> requiredMultipleForms)
        {
            if (!catalog.Realizations.TryGetValue(catalog.CitationCase, out var citation) ||
                citation.Kind != DurationCaseRealizationKind.Authored ||
                citation.Units.Count != 0)
            {
                return;
            }

            var path = $"{catalog.LocaleCode}.phrases.duration";
            var phrases = phrasesValue is null
                ? throw new InvalidOperationException(
                    $"Case-aware citation phrases for '{catalog.LocaleCode}' require the duration phrase surface.")
                : ExpectMapping(phrasesValue, $"{catalog.LocaleCode}.phrases");
            if (!phrases.TryGetValue("duration", out var durationValue))
            {
                throw new InvalidOperationException(
                    $"Case-aware citation phrases for '{catalog.LocaleCode}' require '{path}'.");
            }

            var duration = ExpectMapping(durationValue, path);
            foreach (var unitName in TimeUnits)
            {
                if (!duration.TryGetValue(unitName, out var phraseValue))
                {
                    throw new InvalidOperationException(
                        $"Case-aware citation phrases for '{catalog.LocaleCode}' require '{path}.{unitName}'.");
                }

                ValidateReachableMultipleForms(
                    phraseValue,
                    $"{path}.{unitName}",
                    requiredMultipleForms);
            }
        }

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Add a 'duration' mapping under the 'phrases' section of the locale YAML.
  2. Populate it with entries for every time unit (millisecond, second, minute, hour, day, week, month, year).
  3. Rebuild to confirm the citation case finds its base-duration surface.

Example fix

# before
phrases:
  date: ...
durationCases:
  ...
# after
phrases:
  date: ...
  duration:
    second: ...
    minute: ...
    ...
durationCases:
  ...
Defensive patterns

Strategy: validation

Validate before calling

# Verify phrases.duration exists when durationCases citation case is authored
# python: phrases = yaml.get('phrases', {}); assert 'duration' in phrases

Prevention

When it happens

Trigger: The locale YAML has a 'phrases' block but it contains no 'duration' key (e.g. it only has other phrase categories like 'date' or 'number'), while the durationCases citation case requires duration phrases.

Common situations: A locale's phrases section was authored for other surfaces (dates, numbers) but the duration sub-section was never added, even though the locale declares case-aware duration phrases that depend on it.

Related errors


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