{"record":{"id":"6e6072e629c5660f","repo":"Humanizr/Humanizer","slug":"unsupported-yaml-node","errorCode":null,"errorMessage":"Unsupported YAML node.","messagePattern":"Unsupported YAML node\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs","lineNumber":863,"sourceCode":"        static void AppendYamlValue(StringBuilder builder, SimpleYamlValue value, int indent)\n        {\n            switch (value)\n            {\n                case SimpleYamlMapping mapping:\n                    AppendYamlMapping(builder, mapping, indent);\n                    break;\n\n                case SimpleYamlSequence sequence:\n                    AppendYamlSequence(builder, sequence, indent);\n                    break;\n\n                case SimpleYamlScalar scalar:\n                    builder.Append(' ', indent);\n                    builder.AppendLine(QuoteScalar(scalar));\n                    break;\n\n                default:\n                    throw new InvalidOperationException(\"Unsupported YAML node.\");\n            }\n        }\n\n        static void AppendYamlMapping(StringBuilder builder, SimpleYamlMapping mapping, int indent)\n        {\n            foreach (var entry in mapping.Values)\n            {\n                if (entry.Value is SimpleYamlScalar scalar)\n                {\n                    AppendIndentedScalar(builder, indent, entry.Key, scalar);\n                    continue;\n                }\n\n                builder.Append(' ', indent);\n                builder.Append(entry.Key);\n                builder.AppendLine(\":\");\n                AppendYamlValue(builder, entry.Value, indent + 2);\n            }","sourceCodeStart":845,"sourceCodeEnd":881,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs#L845-L881","documentation":"Thrown by AppendYamlValue during YAML serialization when the value node is not a SimpleYamlMapping, SimpleYamlSequence, or SimpleYamlScalar. This is an internal defensive assertion — the simple YAML model only has three node types, so reaching the default branch indicates either a corrupt node or a new node type was introduced without updating the serializer.","triggerScenarios":"LegacyLocaleMigration's AppendYamlValue is called while building canonical YAML from a legacy mapping. The default case fires if SimpleYamlParser produced a null or a subtype not covered by the three cases. This should never happen with well-formed input from the parser.","commonSituations":"This is effectively a bug indicator, not an authoring error. It may surface if a custom or patched SimpleYamlValue subclass is introduced, or if the YAML parser has a defect producing unexpected node types. Contributors should not normally see this.","solutions":["Report this as a bug — the YAML serializer should handle all SimpleYamlValue subtypes. Check whether SimpleYamlParser was modified to emit a new node type.","Inspect the locale YAML that triggered the serialization to see if it has an unusual structure that confused the parser.","Add the missing node-type case to AppendYamlValue if a legitimate new SimpleYamlValue subtype was introduced."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static bool IsKnownYamlNode(SimpleYamlValue value) =>\n    value is SimpleYamlMapping or SimpleYamlSequence or SimpleYamlScalar;","tryCatchPattern":"// This is an internal assertion — catch only to produce diagnostics, not to recover\ntry\n{\n    LegacyLocaleMigration.ConvertToCanonicalYaml(localeCode, fileText);\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"Unsupported YAML node.\")\n{\n    // This indicates a bug in the YAML parser or model, not an authoring error.\n    // Report it upstream rather than trying to work around it.\n    throw new InvalidOperationException($\"Internal YAML serialization error for locale '{localeCode}'. Report as a bug.\", ex);\n}","preventionTips":["Treat this error as a bug report, not an authoring mistake.","Do not introduce new SimpleYamlValue subtypes without updating AppendYamlValue.","Run the source-generator test suite after modifying SimpleYamlParser."],"tags":["source-generator","yaml","internal-assertion","serialization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}