Humanizr/Humanizer · error · InvalidOperationException

'{path}.provenance' must be a sequence.

Error message

'{path}.provenance' must be a sequence.

What it means

Thrown by ParseProvenance when the 'provenance' key exists but its YAML value is not a SimpleYamlSequence (i.e. not a list). The parser requires provenance to be a sequence of source identifiers.

Source

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

            return result;
        }

        static ImmutableArray<string> ParseProvenance(
            SimpleYamlMapping mapping,
            string path,
            bool required)
        {
            if (!mapping.TryGetValue("provenance", out var value))
            {
                return required
                    ? throw new InvalidOperationException($"'{path}' must define provenance.")
                    : [];
            }

            if (value is not SimpleYamlSequence sequence)
            {
                throw new InvalidOperationException($"'{path}.provenance' must be a sequence.");
            }

            var result = ImmutableArray.CreateBuilder<string>(sequence.Items.Length);
            var seen = new HashSet<string>(StringComparer.Ordinal);
            foreach (var item in sequence.Items)
            {
                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}'.");
                }

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Change the provenance value to a YAML sequence (square-bracket list syntax or block list syntax).
  2. Ensure each element is a scalar string matching a source ID in the sources registry.
  3. Rebuild to confirm the sequence is parsed.

Example fix

# before (scalar instead of sequence)
provenance: cldr-42
# after
provenance: [cldr-42]
Defensive patterns

Strategy: validation

Validate before calling

# Verify provenance is a list, not a scalar or mapping
# python: assert isinstance(unit['provenance'], list), 'provenance must be a sequence'

Prevention

When it happens

Trigger: The 'provenance' key is set to a scalar string (e.g. provenance: cldr-42) or a mapping instead of a YAML list/array.

Common situations: A contributor writes provenance as a single bare string instead of a one-element list, or uses a mapping (key-value pairs) misunderstanding the expected shape.

Related errors


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