{"record":{"id":"2ce9196ce4ef489c","repo":"Humanizr/Humanizer","slug":"inflection-rules-must-be-mappings","errorCode":null,"errorMessage":"Inflection rules must be mappings.","messagePattern":"Inflection rules must be mappings\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs","lineNumber":423,"sourceCode":"            string casing)\n        {\n            if (!mapping.TryGetValue(\"rules\", out var value))\n            {\n                return [];\n            }\n\n            if (value is not SimpleYamlSequence sequence)\n            {\n                throw new InvalidOperationException(\"Inflection rules must be a block sequence.\");\n            }\n\n            var rules = ImmutableArray.CreateBuilder<InflectionRuleInput>();\n            var ids = new HashSet<string>(StringComparer.Ordinal);\n            foreach (var item in sequence.Items)\n            {\n                if (item is not SimpleYamlMapping rule)\n                {\n                    throw new InvalidOperationException(\"Inflection rules must be mappings.\");\n                }\n\n                ValidateProperties(\n                    rule,\n                    \"Inflection rule\",\n                    \"id\", \"direction\", \"priority\", \"scope\", \"match\", \"output\",\n                    \"hostileExclusions\", \"hostile-exclusions\", \"reverse\", \"sources\");\n                var id = GetRequiredScalar(rule, \"id\", \"Inflection rule must define id\");\n                if (!ids.Add(id))\n                {\n                    throw new InvalidOperationException($\"Duplicate inflection rule id '{id}'.\");\n                }\n\n                ValidateSources(rule, sourceIds, $\"Inflection rule '{id}'\");\n                var direction = GetRequiredScalar(rule, \"direction\", $\"Inflection rule '{id}' must define direction\");\n                if (direction is not (\"forward\" or \"reverse\"))\n                {\n                    throw new InvalidOperationException($\"Inflection rule '{id}' has unsupported direction '{direction}'.\");","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs#L405-L441","documentation":"Each item in the 'rules:' sequence must be a YAML mapping describing one rule (id, direction, priority, scope, match, output, ...). ParseRules throws when a list item is a scalar, null, or nested sequence.","triggerScenarios":"A 'rules:' list item is a scalar or sequence instead of a mapping.","commonSituations":"A YAML indentation slip flattening rule keys into the list; pasting a bare id string as a list item.","solutions":["Ensure each item under 'rules:' is a mapping with the required rule keys"],"exampleFix":"# before\n    rules:\n      - 'zz.forward.consonant-y'\n# after\n    rules:\n      - id: 'zz.forward.consonant-y'\n        direction: 'forward'\n        priority: 100\n        scope: { ... }\n        match: { ... }\n        output: { ... }\n        sources: [ 'fixture' ]","handlingStrategy":"validation","validationCode":"foreach (var item in ruleSequence.Items)\n    if (item is not SimpleYamlMapping)\n        Report($\"{locale}: each rules entry must be a mapping.\");","typeGuard":"static bool AllRulesAreMappings(SimpleYamlSequence s) =>\n    s.Items.All(i => i is SimpleYamlMapping);","tryCatchPattern":null,"preventionTips":["Keep rule fields indented under their '- id:' item"],"tags":["inflection","localization","yaml","source-generator","locale","validation"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}