Humanizr/Humanizer · error · InvalidOperationException
Unsupported YAML value node.
Error message
Unsupported YAML value node.
What it means
When serializing parsed locale YAML into JSON for the generated profile, the writer handles three node types: scalar, sequence, and mapping. Reaching the default arm means a SimpleYamlValue subtype was encountered that the serializer does not recognize — an internal invariant violation that should be unreachable with the parser's own node types.
Source
Thrown at src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs:1067
WriteJson(writer, item);
}
writer.WriteEndArray();
break;
case SimpleYamlMapping mapping:
writer.WriteStartObject();
foreach (var entry in mapping.Values)
{
writer.WritePropertyName(entry.Key);
WriteJson(writer, entry.Value);
}
writer.WriteEndObject();
break;
default:
throw new InvalidOperationException("Unsupported YAML value node.");
}
}
static void WriteScalar(Utf8JsonWriter writer, SimpleYamlScalar scalar)
{
if (scalar.IsString)
{
writer.WriteStringValue(scalar.Value);
return;
}
if (string.Equals(scalar.Value, "null", StringComparison.Ordinal))
{
writer.WriteNullValue();
return;
}
if (string.Equals(scalar.Value, "true", StringComparison.OrdinalIgnoreCase))View on GitHub (pinned to ffc2b77c0f)
Solutions
- If you are modifying the generator, add a case arm in WriteJson for the new SimpleYamlValue subtype.
- If you are a locale author, this error indicates a generator bug, not a YAML mistake — report it with the locale file that triggered it.
- Bisect recent generator changes to find where the unrecognized node type was introduced.
Defensive patterns
Strategy: validation
Validate before calling
# This is an internal generator invariant, not a YAML authoring error. # Validate the generator's node model if you modified it: # Ensure every SimpleYamlValue subtype has a case arm in WriteJson. import subprocess # Grep for all SimpleYamlValue subtypes and verify WriteJson coverage # (run only if you are editing the source generator internals) subprocess.run(['grep', '-rn', 'class SimpleYaml', 'src/Humanizer.SourceGenerators/'])
Prevention
- If you add a new SimpleYamlValue subtype, immediately add the corresponding case in WriteJson.
- Locale authors cannot trigger this through YAML — if it fires, file a generator bug report with the reproducing locale file.
- Keep WriteJson's switch exhaustive by treating default as a compile-time error via analyzers where possible.
When it happens
Trigger: Effectively unreachable through normal YAML input because SimpleYamlParser only ever produces SimpleYamlScalar, SimpleYamlSequence, and SimpleYamlMapping nodes. It would only fire if a code change introduced a new SimpleYamlValue subtype without updating WriteJson, or if a null node leaked into the tree.
Common situations: Modifying the source generator internals to add a new YAML value type; a bug in a custom fork that produces malformed node trees.
Related errors
- Locale '{localeCode}.{path}' defines duplicate numeric minut
- Locale '{localeCode}.{path}.{key}' must be a string.
- Locale '{localeCode}.{path}.{key}' must be a non-empty strin
- Locale '{localeCode}.surfaces.number.formatting' defines uns
- Locale '{localeCode}.surfaces.number.formatting' must define
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/1045c04964cc90b3.
Report an issue: GitHub.