{"record":{"id":"a9da6590426e94ee","repo":"Humanizr/Humanizer","slug":"path-must-define-exactly-one-of-phrase-samere","errorCode":null,"errorMessage":"'{path}' must define exactly one of phrase, sameRenderedAs, notApplicable, or unsupported.","messagePattern":"'(.+?)' must define exactly one of phrase, sameRenderedAs, notApplicable, or unsupported\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs","lineNumber":768,"sourceCode":"                throw new InvalidOperationException(\n                    $\"'{path}' contains an unresolved CLDR inheritance marker.\");\n            }\n\n            var mapping = ExpectMapping(value, path);\n            RejectUnknownKeys(\n                mapping,\n                path,\n                [\"phrase\", \"sameRenderedAs\", \"notApplicable\", \"unsupported\", \"provenance\"]);\n            var discriminators = new[]\n            {\n                mapping.TryGetValue(\"phrase\", out _),\n                mapping.GetScalar(\"sameRenderedAs\") is not null,\n                mapping.GetScalar(\"notApplicable\") is not null,\n                mapping.GetScalar(\"unsupported\") is not null\n            };\n            if (discriminators.Count(static enabled => enabled) != 1)\n            {\n                throw new InvalidOperationException(\n                    $\"'{path}' must define exactly one of phrase, sameRenderedAs, notApplicable, or unsupported.\");\n            }\n\n            if (mapping.TryGetValue(\"phrase\", out var phraseValue))\n            {\n                var provenance = ParseProvenance(mapping, path, required: true);\n                ValidateProvenance(provenance, sources, path);\n                ValidateReachableMultipleForms(\n                    phraseValue,\n                    $\"{path}.phrase\",\n                    requiredMultipleForms);\n                var phrase = LocalePhraseNormalization.ParseTimeSpanPhrase(\n                    phraseValue,\n                    $\"{path}.phrase\",\n                    preserveDuplicateForms: !requiredMultipleForms.IsEmpty);\n                if (phrase.Single is null || phrase.Multiple?.Forms is null)\n                {\n                    throw new InvalidOperationException(","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs#L750-L786","documentation":"Thrown when parsing a duration-case unit realization entry (under durationCases.realizations.units.<unit>) that does not contain exactly one of the four mutually-exclusive discriminator keys: phrase, sameRenderedAs, notApplicable, or unsupported. The generator builds a four-element boolean array from these keys and requires the count of enabled discriminators to be exactly 1, so both zero and two-or-more trigger the error.","triggerScenarios":"A locale YAML unit realization block has no discriminator (e.g. only a 'provenance' key), or has more than one (e.g. both 'phrase' and 'sameRenderedAs', or 'notApplicable' and 'unsupported' on the same entry).","commonSituations":"A locale contributor adds a new unit realization and forgets to specify how it should be rendered, or copies an existing block and leaves both an old 'phrase' and a new 'notApplicable' when switching strategies. Also occurs when an author intends 'sameAsNominative' (a case-overlay concept) inside a realization block where it is not a valid discriminator.","solutions":["Open the locale YAML at the path reported in the error and navigate to the indicated unit realization entry.","Ensure the entry contains exactly one of: phrase (a mapping), sameRenderedAs (scalar targeting another case), notApplicable (scalar reason), or unsupported (scalar reason).","Remove any extra discriminator keys so only one remains; if none is present, add the one matching the intended rendering strategy.","Rebuild to confirm the source generator accepts the entry."],"exampleFix":"# before (zero discriminators)\nsecond:\n  provenance: [cldr]\n# after\nsecond:\n  sameRenderedAs: nominative\n  provenance: [cldr]","handlingStrategy":"validation","validationCode":"# Before building, check each unit realization has exactly one discriminator\n# PowerShell pre-build check (run from repo root)\n$ErrorActionPreference = 'Stop'\n$locales = Get-ChildItem src/Humanizer/Locales/*.yml\nforeach ($f in $locales) {\n    $yaml = Get-Content $f.FullName -Raw\n    # crude regex: find realization unit blocks and count discriminators\n    if ($yaml -match 'realizations:') {\n        Write-Host \"Checking $($f.Name) for discriminator validity...\"\n        # Full schema validation is recommended via a YAML parser\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a YAML schema or template for durationCases.realizations.units entries that shows exactly one discriminator per block.","Run a dotnet build after every locale edit to surface source-generator errors immediately.","Review the add-locale skill and contributing docs before authoring duration-case realizations."],"tags":["humanizer","locale","yaml","source-generator","duration-cases","build-time"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}