Humanizr/Humanizer · error · ArgumentOutOfRangeException
Unknown ordinal date profile.
Error message
Unknown ordinal date profile.
What it means
This message is emitted into generated source code (OrdinalDateProfileCatalog.DateTo.g.cs or .DateOnly.g.cs) as the default case of the Resolve switch. At runtime, DateToOrdinalWordsProfileCatalog.Resolve(kind) or DateOnlyToOrdinalWordsProfileCatalog.Resolve(kind) throws ArgumentOutOfRangeException when the kind string does not match any compiled ordinal-date profile name.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/OrdinalDateProfileCatalogInput.cs:141
builder.AppendLine();
builder.AppendLine("{");
builder.Append(" public static ");
builder.Append(interfaceName);
builder.AppendLine(" Resolve(string kind)");
builder.AppendLine(" {");
builder.AppendLine(" switch (kind)");
builder.AppendLine(" {");
foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))
{
builder.Append(" case ");
builder.Append(QuoteLiteral(profile.ProfileName));
builder.Append(": return ");
builder.Append(GetCatalogPropertyName(profile.ProfileName));
builder.AppendLine(";");
}
builder.AppendLine(" default: throw new ArgumentOutOfRangeException(nameof(kind), kind, \"Unknown ordinal date profile.\");");
builder.AppendLine(" }");
builder.AppendLine(" }");
builder.AppendLine();
foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))
{
AppendLazyCachedMember(
builder,
" ",
"static",
interfaceName,
GetCatalogPropertyName(profile.ProfileName),
CreateConverterExpression(profile, converterTypeName));
builder.AppendLine();
}
builder.AppendLine("}");
View on GitHub (pinned to ffc2b77c0f)
Solutions
- Verify the target locale has an ordinal-date YAML block with the correct profile name under src/Humanizer/Locales.
- Ensure the ordinal-date feature is registered with UsesGeneratedProfile: true.
- Fall back to a known-supported locale (e.g. 'en-US') for ordinal-date conversion if the requested locale is not supported.
- Check that the culture name you pass matches exactly (including casing and hyphens) the profile name compiled into the catalog.
Example fix
// before — locale 'xx' has no ordinal-date profile
var words = date.ToOrdinalWords(new CultureInfo("xx"));
// after — use a supported locale
var words = date.ToOrdinalWords(new CultureInfo("en-US")); Defensive patterns
Strategy: validation
Validate before calling
// Before calling an ordinal-date API with an arbitrary locale, verify support.
var culture = new CultureInfo("en-US");
// Use public APIs which fall back gracefully; if calling the internal catalog directly,
// guard the profile name. Try / catch
try
{
var converter = DateToOrdinalWordsProfileCatalog.Resolve(kind);
}
catch (ArgumentOutOfRangeException)
{
converter = DateToOrdinalWordsProfileCatalog.Resolve("en-US");
} Prevention
- Use the public date.ToOrdinalWords() extension methods rather than calling internal catalogs.
- Verify that the target culture is shipped in src/Humanizer/Locales with an ordinal-date block.
- Test ordinal-date conversion for each locale your application supports.
When it happens
Trigger: Calling a date-to-ordinal-words API (e.g. date.ToOrdinalWords()) with a culture whose ordinal-date feature is not registered or whose profile name differs from what the catalog compiled. The generated catalog only contains profiles from locales with UsesGeneratedProfile: true.
Common situations: A consumer requests ordinal-date conversion for a locale that has no ordinal-date YAML block, or whose ordinal-date profile name doesn't match the culture identifier being passed. Common after upgrading Humanizer when locale profile names change.
Related errors
- Unknown number-to-words profile.
- Unknown ordinalizer profile.
- Unknown clock-notation profile.
- Unknown words-to-number profile.
- Specified argument was out of the range of valid values. (Pa
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/8e253ae3c0e01794.
Report an issue: GitHub.