{"record":{"id":"ee565f2eb451f394","repo":"Humanizr/Humanizer","slug":"distinct-duration-cases-for-localecode-must-de-ee565f","errorCode":null,"errorMessage":"Distinct duration cases for '{localeCode}' must define at least one case.","messagePattern":"Distinct duration cases for '(.+?)' must define at least one case\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs","lineNumber":381,"sourceCode":"            var cases = ImmutableDictionary.CreateBuilder<string, DurationCaseOverlay>(StringComparer.Ordinal);\n            foreach (var caseName in casesMapping.Values.Keys\n                         .OrderBy(static name => name, StringComparer.Ordinal)\n                         .Where(caseName => !Cases.Contains(caseName, StringComparer.Ordinal) || caseName == \"nominative\"))\n            {\n                throw new InvalidOperationException(\n                    $\"'{path}.cases' defines unsupported non-nominative case '{caseName}'.\");\n            }\n\n            foreach (var caseName in Cases\n                         .Where(static caseName => caseName != \"nominative\")\n                         .Where(casesMapping.Values.ContainsKey))\n            {\n                cases[caseName] = ParseCase(casesMapping.Values[caseName], $\"{path}.cases.{caseName}\");\n            }\n\n            if (cases.Count == 0)\n            {\n                throw new InvalidOperationException($\"Distinct duration cases for '{localeCode}' must define at least one case.\");\n            }\n\n            return new DurationCaseCatalog(\n                localeCode,\n                classification,\n                \"nominative\",\n                [\"nominative\", .. cases.Keys.OrderBy(static name => name, StringComparer.Ordinal)],\n                EmptyRealizations(),\n                EmptySources(),\n                cases.ToImmutable().Add(\"nominative\", CreateBaseDurationOverlay()));\n        }\n\n        internal static DurationCaseCatalog ParseForTests(\n            string localeCode,\n            string text,\n            string? casePluralRule = null,\n            string? phrasesText = null)\n        {","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs#L363-L399","documentation":"Thrown by ParseLegacyForTests when classification is 'distinct', a 'cases' block is present, but after filtering out unsupported names and nominative, zero valid cases remain. Distinct classification requires at least one non-nominative grammatical case with authored data.","triggerScenarios":"After iterating casesMapping keys for unsupported/nominative entries (error 56) and iterating known non-nominative cases present in the mapping, if cases.Count == 0 the throw fires. For example 'cases:\\n  nominative: { ... }' where nominative is rejected and no other valid case is present.","commonSituations":"A contributor writes a cases block containing only 'nominative' (which is rejected by error 56 logic) or only invalid names, leaving zero valid entries. Or the cases block is an empty mapping 'cases: {}'.","solutions":["Add at least one valid non-nominative case (e.g. genitive, dative, accusative) to the cases mapping.","If the locale has no case distinctions, change classification from 'distinct' to 'same-as-nominative' or 'not-applicable'.","Ensure the cases block is a non-empty YAML mapping with recognized case names."],"exampleFix":"# before (only nominative, which is rejected)\ndurationCases:\n  classification: distinct\n  cases:\n    nominative: { ... }\n# after (at least one valid non-nominative case)\ndurationCases:\n  classification: distinct\n  cases:\n    genitive: { ... }","handlingStrategy":"validation","validationCode":"// Distinct classification needs at least one valid non-nominative case\nstatic bool DistinctHasAtLeastOneCase(SimpleYamlMapping durationCases,\n    HashSet<string> supportedCases)\n{\n    if (durationCases.GetScalar(\"classification\") != \"distinct\") return true;\n    if (!durationCases.TryGetValue(\"cases\", out var casesVal) || casesVal is not SimpleYamlMapping casesMap)\n        return false;\n    return casesMap.Values.Keys.Any(k => k != \"nominative\" && supportedCases.Contains(k));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Distinct durationCases must include at least one valid non-nominative case (e.g. genitive).","If no case distinctions exist, don't use 'distinct' — use 'same-as-nominative' or 'not-applicable'.","Avoid empty cases mappings — they always fail this check."],"tags":["source-generator","duration-cases","legacy-format","testing","grammar"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}