Humanizr/Humanizer · error · InvalidOperationException
'{path}.provenance' references unknown source '{sourceId}'.
Error message
'{path}.provenance' references unknown source '{sourceId}'. What it means
Thrown by ValidateProvenance when a source ID in the provenance sequence does not match any key in the locale's sources dictionary. Every provenance entry must reference a source defined in the durationCases.sources section.
Source
Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:1086
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) =>
mapping.GetScalar(key)
?? throw new InvalidOperationException($"'{path}' must define scalar '{key}'.");
static string RequireReason(string reason, string path) =>
string.IsNullOrWhiteSpace(reason)
? throw new InvalidOperationException($"'{path}' must not be empty.")
: reason;
static ImmutableDictionary<string, DurationCaseRealization> EmptyRealizations() =>
ImmutableDictionary<string, DurationCaseRealization>.Empty.WithComparers(StringComparer.Ordinal);
static DurationCaseOverlay CreateBaseDurationOverlay()
{View on GitHub (pinned to ffc2b77c0f)
Solutions
- Check the source ID named in the error message against the locale's 'sources' section.
- Either add a source entry with that ID (including kind, url, revision, locator, and credit fields) or correct the provenance reference to match an existing source ID.
- Rebuild to confirm all provenance references resolve.
Example fix
# before — provenance references 'cldr-43' but sources only defines 'cldr-42'
sources:
cldr-42:
kind: cldr
url: ...
...
second:
phrase: ...
provenance: [cldr-43]
# after
second:
phrase: ...
provenance: [cldr-42] Defensive patterns
Strategy: validation
Validate before calling
# Verify every provenance source ID exists in the sources registry
# python: source_ids = set(yaml['durationCases']['sources'].keys())
# for unit in all_units:
# for sid in unit.get('provenance', []):
# assert sid in source_ids, f'unknown source {sid}' Prevention
- Declare all source entries in the sources section before referencing them in provenance.
- When renaming a source ID, update all provenance references simultaneously.
- Use a script or IDE find-and-replace to keep source IDs consistent across the file.
When it happens
Trigger: A unit realization's provenance lists a source ID (e.g. 'cldr-42') but no matching entry exists in the locale's sources registry.
Common situations: A contributor adds a new source ID to a provenance list but forgets to declare the corresponding source object in the 'sources' section. Also occurs when a source ID is renamed in the sources section but not updated in provenance references, or vice versa.
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' must not be empty.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/6045fdd3b5b569cc.
Report an issue: GitHub.