{"record":{"id":"5e1d9bab2d2477a9","repo":"Humanizr/Humanizer","slug":"path-must-be-a-mapping","errorCode":null,"errorMessage":"'{path}' must be a mapping.","messagePattern":"'(.+?)' must be a mapping\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs","lineNumber":1200,"sourceCode":"                throw new InvalidOperationException(\n                    $\"Case overlay '{path}' must explicitly define singular and numeric multiple forms.\");\n            }\n\n            return new DurationCaseUnit(DurationCaseUnitKind.Phrase, phrase);\n        }\n\n        static bool ContainsInheritanceMarker(SimpleYamlValue value) =>\n            value switch\n            {\n                SimpleYamlScalar scalar => scalar.Value.Contains(\"↑↑↑\", StringComparison.Ordinal),\n                SimpleYamlMapping mapping => mapping.Values.Values.Any(ContainsInheritanceMarker),\n                SimpleYamlSequence sequence => sequence.Items.Any(ContainsInheritanceMarker),\n                _ => false\n            };\n\n        static SimpleYamlMapping ExpectMapping(SimpleYamlValue value, string path) =>\n            value as SimpleYamlMapping\n            ?? throw new InvalidOperationException($\"'{path}' must be a mapping.\");\n\n        static void RejectUnknownKeys(SimpleYamlMapping mapping, string path, IReadOnlyCollection<string> supported)\n        {\n            foreach (var key in mapping.Values.Keys.Where(key => !supported.Contains(key)))\n            {\n                throw new InvalidOperationException(\n                    $\"'{path}' defines unsupported property '{key}'. Supported properties: {string.Join(\", \", supported)}.\");\n            }\n        }\n    }\n}","sourceCodeStart":1182,"sourceCodeEnd":1211,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs#L1182-L1211","documentation":"ExpectMapping (DurationCaseModels.cs:1198-1200) casts a parsed YAML node to SimpleYamlMapping and throws when the node is actually a scalar or a sequence. Duration-case parsing requires mappings at the case, units, and unit levels; any node that collapsed to a scalar/list (often a YAML indentation error) fails here.","triggerScenarios":"A YAML node expected to be key:value is a bare scalar or a dash list — e.g. 'units: second' instead of 'units: { second: {...} }', or a unit value that is a plain string.","commonSituations":"YAML indentation/typo that flattens a mapping into a scalar; using a '-' sequence where a ':' mapping is required; missing colon after a key.","solutions":["Fix the YAML so the node is a mapping (indented 'key: value' pairs).","Check indentation against a known-good locale (e.g. src/Humanizer/Locales/cs.yml) at the same structural level.","Validate the file with a YAML linter before building."],"exampleFix":"# before - units is a scalar, not a mapping\ncases:\n  genitive: second\n# after\ncases:\n  genitive:\n    units:\n      second:\n        sameAsNominative: true","handlingStrategy":"validation","validationCode":"# Validate that case/units/unit nodes are mappings before building\nfunction Assert-IsMapping($node, $path) {\n    if ($null -eq $node -or -not ($node -is [hashtable])) {\n        throw \"'$path' must be a YAML mapping (key: value), got $(($node | Out-String).Trim())\"\n    }\n}\nAssert-IsMapping $parsed.durationCases.cases.$case \"$locale.cases.$case\"\nAssert-IsMapping $parsed.durationCases.cases.$case.units \"$locale.cases.$case.units\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a YAML linter that rejects scalar/list nodes where mappings are expected.","Indent case/units/unit levels consistently; model new locales on cs.yml.","After editing, parse the file and assert the expected nodes are mappings."],"tags":["source-generator","build-time","localization","yaml","duration-cases","locale-data"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}