Humanizr/Humanizer · error · InvalidOperationException
'{path}.provenance' must contain non-empty source identifier
Error message
'{path}.provenance' must contain non-empty source identifiers. What it means
Thrown by ParseProvenance when iterating the provenance sequence and encountering an item that is not a SimpleYamlScalar or whose scalar value is empty/whitespace. Every provenance entry must be a non-empty source identifier string.
Source
Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:1058
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}'.");
}
result.Add(scalar.Value);
}
if (required && result.Count == 0)
{
throw new InvalidOperationException($"'{path}.provenance' must not be empty.");
}
return result.MoveToImmutable();View on GitHub (pinned to ffc2b77c0f)
Solutions
- Inspect each element of the provenance list at the reported path.
- Remove or replace any non-scalar or empty/whitespace entries with a valid non-empty source ID string.
- Rebuild to confirm all entries are valid scalars.
Example fix
# before (empty entry from trailing comma) provenance: [cldr-42, ] # after provenance: [cldr-42]
Defensive patterns
Strategy: validation
Validate before calling
# Verify every provenance item is a non-empty string # python: for item in unit['provenance']: # assert isinstance(item, str) and item.strip(), 'empty or non-scalar provenance entry'
Prevention
- Avoid trailing commas in flow-style YAML lists that create empty entries.
- Keep each provenance entry as a bare scalar string.
- Run a YAML linter that flags empty list elements.
When it happens
Trigger: The provenance list contains a null/empty element, a mapping, a nested sequence, or a scalar value that is whitespace-only.
Common situations: A contributor leaves a trailing comma in a flow-style list creating an empty entry, or accidentally nests a mapping inside the provenance list. Also occurs when a source ID is accidentally left blank.
Related errors
- '{path}' must define provenance.
- '{path}.provenance' must be a sequence.
- '{path}.provenance' contains duplicate source '{scalar.Value
- '{path}.provenance' must not be empty.
- '{path}.provenance' references unknown source '{sourceId}'.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/4eda2bd625ae7601.
Report an issue: GitHub.