{"record":{"id":"b5757bed2e0e8ec4","repo":"Humanizr/Humanizer","slug":"path-must-define-all-duration-units","errorCode":null,"errorMessage":"'{path}' must define all duration 'units'.","messagePattern":"'(.+?)' must define all duration 'units'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs","lineNumber":1127,"sourceCode":"            }\n\n            return new DurationCaseOverlay(units.ToImmutable());\n        }\n\n        static ImmutableDictionary<string, DurationCaseUnitRealization> EmptyUnitRealizations() =>\n            ImmutableDictionary<string, DurationCaseUnitRealization>.Empty.WithComparers(StringComparer.Ordinal);\n\n        static ImmutableDictionary<string, DurationCaseSource> EmptySources() =>\n            ImmutableDictionary<string, DurationCaseSource>.Empty.WithComparers(StringComparer.Ordinal);\n\n        static DurationCaseOverlay ParseCase(SimpleYamlValue value, string path)\n        {\n            var mapping = ExpectMapping(value, path);\n            RejectUnknownKeys(mapping, path, [\"units\"]);\n\n            if (!mapping.TryGetValue(\"units\", out var unitsValue))\n            {\n                throw new InvalidOperationException($\"'{path}' must define all duration 'units'.\");\n            }\n\n            var unitsMapping = ExpectMapping(unitsValue, $\"{path}.units\");\n            RejectUnknownKeys(unitsMapping, $\"{path}.units\", TimeUnits);\n            var units = ImmutableDictionary.CreateBuilder<string, DurationCaseUnit>(StringComparer.Ordinal);\n            foreach (var unitName in TimeUnits)\n            {\n                if (!unitsMapping.TryGetValue(unitName, out var unitValue))\n                {\n                    throw new InvalidOperationException(\n                        $\"'{path}.units' must explicitly define '{unitName}'.\");\n                }\n\n                units[unitName] = ParseUnit(unitValue, $\"{path}.units.{unitName}\");\n            }\n\n            return new DurationCaseOverlay(units.ToImmutable());\n        }","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs#L1109-L1145","documentation":"Thrown by ParseCase when a case overlay entry (under durationCases.cases.<caseName>) does not contain a 'units' key. Every case overlay must define all eight duration units explicitly, so the parser rejects an entry that omits the units mapping entirely.","triggerScenarios":"A case overlay entry in the 'cases' section of durationCases lacks the 'units' key, so TryGetValue('units', ...) returns false.","commonSituations":"A contributor adds a new case to the cases section but only provides metadata or a partial structure without the units mapping. Also occurs when a contributor confuses the case-overlay format (which needs 'units') with the realization format (which uses discriminators like phrase/sameRenderedAs).","solutions":["Add a 'units' mapping to the case overlay entry at the reported path.","Populate it with all eight time units (millisecond, second, minute, hour, day, week, month, year), each specifying a phrase, sameAsNominative, or unsupported value.","Rebuild to confirm the case overlay is accepted."],"exampleFix":"# before (case overlay missing 'units')\naccusative:\n  citation: Acc\n# after\naccusative:\n  units:\n    millisecond:\n      sameAsNominative: true\n    second:\n      sameAsNominative: true\n    minute:\n      sameAsNominative: true\n    hour:\n      sameAsNominative: true\n    day:\n      sameAsNominative: true\n    week:\n      sameAsNominative: true\n    month:\n      sameAsNominative: true\n    year:\n      sameAsNominative: true","handlingStrategy":"validation","validationCode":"# Verify every case overlay in durationCases.cases has a 'units' key\n# python: for case_name, case in yaml['durationCases']['cases'].items():\n#     assert 'units' in case, f'case {case_name} missing units'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a case to the cases section, immediately add the 'units' mapping with all eight time units.","Copy a complete case overlay block from an existing locale and adapt it.","Build after adding each case to catch missing-units errors at the specific path."],"tags":["humanizer","locale","yaml","source-generator","duration-cases","case-overlay","build-time"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}