Humanizr/Humanizer · error · InvalidOperationException

'{path}.provenance' must not be empty.

Error message

'{path}.provenance' must not be empty.

What it means

Thrown by ParseProvenance when required is true, the provenance key exists and is a valid sequence, but the sequence contains zero items. After iterating, the parser checks result.Count == 0 and throws if the list is empty.

Source

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

            {
                if (item is not SimpleYamlScalar scalar || string.IsNullOrWhiteSpace(scalar.Value))
                {
                    throw new InvalidOperationException(
                        $"'{path}.provenance' must contain non-empty source identifiers.");
                }

                if (!seen.Add(scalar.Value))
                {
                    throw new InvalidOperationException(
                        $"'{path}.provenance' contains duplicate source '{scalar.Value}'.");
                }

                result.Add(scalar.Value);
            }

            if (required && result.Count == 0)
            {
                throw new InvalidOperationException($"'{path}.provenance' must not be empty.");
            }

            return result.MoveToImmutable();
        }

        static void ValidateProvenance(
            ImmutableArray<string> provenance,
            ImmutableDictionary<string, DurationCaseSource> sources,
            string path)
        {
            foreach (var sourceId in provenance.Where(sourceId => !sources.ContainsKey(sourceId)))
            {
                throw new InvalidOperationException(
                    $"'{path}.provenance' references unknown source '{sourceId}'.");
            }
        }

        static string RequireScalar(SimpleYamlMapping mapping, string key, string path) =>

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Populate the provenance sequence with at least one valid source ID defined in the locale's sources registry.
  2. Rebuild to confirm the non-empty provenance is accepted.

Example fix

# before
provenance: []
# after
provenance: [cldr-42]
Defensive patterns

Strategy: validation

Validate before calling

# Verify required provenance is non-empty
# python: if required: assert len(unit['provenance']) > 0, 'provenance must not be empty'

Prevention

When it happens

Trigger: The 'provenance' key is present and is a valid YAML sequence, but the sequence is empty (e.g. provenance: []).

Common situations: A contributor adds the provenance key as an empty list as a placeholder, or a YAML template generates an empty sequence. The generator requires at least one source for phrase, sameRenderedAs, and notApplicable realizations.

Related errors


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