{"record":{"id":"86f8953e7eb61729","repo":"Humanizr/Humanizer","slug":"inflection-defines-unsupported-quantity-selector","errorCode":null,"errorMessage":"Inflection defines unsupported quantity selector; expected 'exact-numeric-singleton'.","messagePattern":"Inflection defines unsupported quantity selector; expected 'exact-numeric-singleton'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs","lineNumber":162,"sourceCode":"                    NormalizeGuards(\n                        GetOptionalStrings(mapping, \"skipSimpleWords\", \"skip-simple-words\"),\n                        casing,\n                        scripts,\n                        \"skipSimpleWords\"),\n                    lexemes,\n                    rules));\n        }\n\n        static string? ParseQuantitySelector(SimpleYamlMapping mapping)\n        {\n            if (!mapping.TryGetValue(\"quantitySelector\", out var value))\n            {\n                return null;\n            }\n\n            return value is SimpleYamlScalar { Value: ExactNumericSingletonSelector }\n                ? ExactNumericSingletonSelector\n                : throw new InvalidOperationException(\n                    \"Inflection defines unsupported quantity selector; expected 'exact-numeric-singleton'.\");\n        }\n\n        static void ValidateQuantitySelector(\n            SimpleYamlMapping mapping,\n            string cardinalRule,\n            string? quantitySelector,\n            ImmutableArray<InflectionLexemeInput> lexemes,\n            ImmutableArray<InflectionRuleInput> rules)\n        {\n            var hasOptedLexeme = lexemes.Any(static lexeme =>\n                lexeme.Display.ContainsKey(\"one\"));\n            if (quantitySelector is not null)\n            {\n                if (!hasOptedLexeme)\n                {\n                    throw new InvalidOperationException(\n                        \"Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display.\");","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs#L144-L180","documentation":"The inflection surface accepts an optional 'quantitySelector' key, but the only supported value is the literal string 'exact-numeric-singleton'. ParseQuantitySelector throws when the key is present with any other value. The throw is caught during catalog collection and surfaced as an HSG003 diagnostic, which suppresses that locale's generated inflection catalog.","triggerScenarios":"A locale YAML sets 'quantitySelector:' under 'surfaces.inflection' to anything other than 'exact-numeric-singleton' (e.g. 'nearest-numeric-singleton', a typo, or a scalar with different casing).","commonSituations":"Authoring a new locale that needs per-number singular/plural behavior and guessing the selector name; copy-paste from an unrelated spec; renaming the key during a refactor without checking the parser's single accepted constant.","solutions":["Set the value to exactly 'exact-numeric-singleton'","Remove the quantitySelector key entirely if the locale does not need singleton-one selection"],"exampleFix":"# before\n    quantitySelector: 'nearest-numeric-singleton'\n# after\n    quantitySelector: 'exact-numeric-singleton'","handlingStrategy":"validation","validationCode":"// In a locale-YAML lint pass, before building:\n// 1. Parse surfaces.inflection into a SimpleYamlMapping `m`.\n// 2. If m contains 'quantitySelector', its scalar must be exactly:\nif (m.TryGetValue(\"quantitySelector\", out var v) &&\n    (v is not SimpleYamlScalar s || s.Value != \"exact-numeric-singleton\"))\n{\n    Report($\"{locale}: quantitySelector must be 'exact-numeric-singleton' or absent.\");\n}","typeGuard":"static bool IsValidQuantitySelector(SimpleYamlMapping m) =>\n    !m.TryGetValue(\"quantitySelector\", out var v) ||\n    v is SimpleYamlScalar { Value: \"exact-numeric-singleton\" };","tryCatchPattern":null,"preventionTips":["Keep quantitySelector absent unless you specifically need singular-quantity selection","Copy from ExactNumericSingletonInflectionFixture when enabling it","Run 'dotnet build' after every locale edit; HSG003 points at the offending locale"],"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"}