{"record":{"id":"9dbaf2284465d9e0","repo":"Humanizr/Humanizer","slug":"unexpected-end-of-yaml-document","errorCode":null,"errorMessage":"Unexpected end of YAML document.","messagePattern":"Unexpected end of YAML document\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs","lineNumber":1416,"sourceCode":"                if (c == '#' && !inSingleQuote && !inDoubleQuote)\n                {\n                    break;\n                }\n\n                builder.Append(c);\n            }\n\n            return builder.ToString().TrimEnd();\n        }\n\n        static SimpleYamlValue ParseBlock(\n            IReadOnlyList<LineInfo> lines,\n            ref int index,\n            int indent,\n            bool rejectDuplicateKeys)\n        {\n            return index >= lines.Count\n                ? throw new InvalidOperationException(\"Unexpected end of YAML document.\")\n                : IsSequenceItem(lines[index].Content)\n                ? ParseSequence(lines, ref index, indent, rejectDuplicateKeys)\n                : ParseMapping(lines, ref index, indent, rejectDuplicateKeys);\n        }\n\n        static SimpleYamlSequence ParseSequence(\n            IReadOnlyList<LineInfo> lines,\n            ref int index,\n            int indent,\n            bool rejectDuplicateKeys)\n        {\n            var items = ImmutableArray.CreateBuilder<SimpleYamlValue>();\n\n            while (index < lines.Count)\n            {\n                var line = lines[index];\n                if (line.Indent < indent)\n                {","sourceCodeStart":1398,"sourceCodeEnd":1434,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs#L1398-L1434","documentation":"The parser's ParseBlock entry point expects at least one line at the current indent level to begin a sequence or mapping. If the line index has already consumed all lines when a block is required — typically because a parent node implied children that are absent — it throws rather than returning an empty or ambiguous node.","triggerScenarios":"A locale YAML structure implies a nested block that is missing: for example a sequence item '- ' with no following content at deeper indent, or a mapping key followed by end-of-file with no value.","commonSituations":"Truncating a locale file mid-structure; deleting child lines but leaving the parent key; a merge conflict artifact leaving a dangling parent key.","solutions":["Inspect the end of the file for a key or sequence marker with no value below it.","Add the expected child content or remove the orphaned parent key.","Run a YAML linter on the file to locate the structural break."],"exampleFix":"# before — key with no value at EOF\nformatter:\n  engine: default\ncalendar:\n\n# after — provide value or remove key\nformatter:\n  engine: default","handlingStrategy":"validation","validationCode":"# A standard YAML parser will flag truncated/dangling structures.\nimport yaml, pathlib\nlocales_dir = pathlib.Path('src/Humanizer/Locales')\nfor f in locales_dir.rglob('*.yml'):\n    try:\n        yaml.safe_load(f.read_text())\n    except yaml.YAMLError as e:\n        print(f'{f.name}: YAML parse error (possible dangling key): {e}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid leaving a mapping key with no value at the end of the file.","Run a standard YAML linter before building to catch truncated structures.","Watch for merge-conflict residue leaving dangling parent keys."],"tags":["locale","yaml","source-generator","parser","eof"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}