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
- Populate the provenance sequence with at least one valid source ID defined in the locale's sources registry.
- 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
- Never leave provenance as an empty list placeholder; populate it with at least one source ID.
- If unsure of the source, add a placeholder source entry and reference it, then update later.
- Build immediately after adding the provenance key to catch empty-list errors.
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
- '{path}' must define provenance.
- '{path}.provenance' must be a sequence.
- '{path}.provenance' must contain non-empty source identifier
- '{path}.provenance' contains duplicate source '{scalar.Value
- '{path}.provenance' references unknown source '{sourceId}'.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/e71d799a12729755.
Report an issue: GitHub.