{"record":{"id":"1c278641f1013689","repo":"Humanizr/Humanizer","slug":"unsupported-indentation-on-line-linenumber-1","errorCode":null,"errorMessage":"Unsupported indentation on line {lineNumber + 1}. Locale YAML uses 2-space indentation.","messagePattern":"Unsupported indentation on line (.+?)\\. Locale YAML uses 2-space indentation\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs","lineNumber":1359,"sourceCode":"            var lines = text.Split([\"\\r\\n\", \"\\n\"], StringSplitOptions.None);\n\n            for (var lineNumber = 0; lineNumber < lines.Length; lineNumber++)\n            {\n                var rawLine = StripComment(lines[lineNumber]);\n                if (string.IsNullOrWhiteSpace(rawLine))\n                {\n                    continue;\n                }\n\n                var indent = 0;\n                while (indent < rawLine.Length && rawLine[indent] == ' ')\n                {\n                    indent++;\n                }\n\n                if ((indent & 1) != 0)\n                {\n                    throw new InvalidOperationException($\"Unsupported indentation on line {lineNumber + 1}. Locale YAML uses 2-space indentation.\");\n                }\n\n                result.Add(new LineInfo(indent, rawLine.Trim(), lineNumber + 1));\n            }\n\n            return result;\n        }\n\n        static string StripComment(string line)\n        {\n            var builder = new StringBuilder(line.Length);\n            var inSingleQuote = false;\n            var inDoubleQuote = false;\n\n            for (var i = 0; i < line.Length; i++)\n            {\n                var c = line[i];\n                if (c == '\\'' && !inDoubleQuote)","sourceCodeStart":1341,"sourceCodeEnd":1377,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs#L1341-L1377","documentation":"The locale YAML parser is intentionally minimal and only supports even-width (2-space-multiple) indentation. It counts leading spaces and rejects any line whose indent count is odd, because the parser's indent arithmetic relies on multiples of two to infer nesting depth.","triggerScenarios":"Any non-blank locale YAML line has an odd number of leading spaces (1, 3, 5, ...) or uses tab characters (tabs are not counted as space indentation and shift the count). The {lineNumber+1} placeholder names the offending line.","commonSituations":"Mixing tabs and spaces; using 4-space indentation in some lines and 2 in others; editor auto-indent inserting an odd space count; pasting content from a source with different indent width.","solutions":["Replace tabs with spaces and ensure every indent level is exactly 2 spaces.","Check the line number in the message and fix the leading whitespace to an even count.","Configure your editor to insert spaces for tabs with a 2-space indent width for locale YAML files."],"exampleFix":"# before — 3-space indent (odd)\nformatter:\n   engine: default\n\n# after — 2-space indent (even)\nformatter:\n  engine: default","handlingStrategy":"validation","validationCode":"# Check every non-blank line for odd indentation or tabs.\nimport pathlib\nlocales_dir = pathlib.Path('src/Humanizer/Locales')\nfor f in locales_dir.rglob('*.yml'):\n    for i, line in enumerate(f.read_text().splitlines(), 1):\n        stripped = line.lstrip(' ')\n        if stripped == line.lstrip():\n            continue  # no leading spaces\n        indent = len(line) - len(stripped)\n        if '\\t' in line[:indent + 1]:\n            print(f'{f.name}:{i}: tab character in indentation')\n        if indent % 2 != 0:\n            print(f'{f.name}:{i}: odd indentation ({indent} spaces)')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 2-space indentation exclusively for all locale YAML files — no tabs, no odd counts.","Configure your editor with .editorconfig or settings to insert 2 spaces for YAML files.","Run an indentation lint as a pre-commit hook on locale files."],"tags":["locale","yaml","source-generator","parser","indentation"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}