{"record":{"id":"908f1d643aff6295","repo":"Humanizr/Humanizer","slug":"unexpected-east-asian-scale-builder","errorCode":null,"errorMessage":"Unexpected east-asian scale builder.","messagePattern":"Unexpected east-asian scale builder\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/NumberToWordsEngineContractFactory.cs","lineNumber":510,"sourceCode":"                ? root\n                : EngineContractUtilities.GetRequiredElement(root, member.SourcePath);\n\n            // Builders exist for repeated structured rows such as scale tables, suffix rules, and\n            // gender-ending records. Keeping these explicit makes the generated output easier to\n            // audit than trying to encode a second generic mini-language for nested collections.\n            return member.Builder switch\n            {\n                \"harmony-ordinal-scale-array\" => CreateHarmonyOrdinalScaleArrayExpression(builderRoot),\n                \"billion-strategy-cardinal-scale-array\" => CreateBillionStrategyCardinalScaleArrayExpression(builderRoot),\n                \"contracted-one-scale-array\" => CreateContractedOneScaleArrayExpression(builderRoot),\n                \"linking-scale-array\" => CreateLinkingScaleArrayExpression(builderRoot),\n                \"linking-suffix-rule-array\" => CreateLinkingSuffixRuleArrayExpression(builderRoot),\n                \"agglutinative-ordinal-scale-array\" => CreateAgglutinativeOrdinalScaleArrayExpression(builderRoot),\n                \"contextual-decimal-scale-array\" => CreateContextualDecimalScaleArrayExpression(builderRoot),\n                \"conjunctional-scale-array\" => CreateConjunctionalScaleArrayExpression(builderRoot),\n                \"joined-scale-array\" => CreateJoinedScaleArrayExpression(builderRoot),\n                \"west-slavic-scale-forms\" => CreateWestSlavicScaleFormsExpression(builderRoot),\n                \"east-asian-scale-array\" => throw new InvalidOperationException(\"Unexpected east-asian scale builder.\"),\n                \"east-slavic-scale-array\" => CreateEastSlavicScaleArrayExpression(builderRoot),\n                \"east-slavic-gender-ending\" => CreateEastSlavicGenderEndingExpression(builderRoot),\n                \"pluralized-scale-array\" => CreatePluralizedScaleArrayExpression(builderRoot),\n                \"ordinal-prefix-scale-array\" => CreateOrdinalPrefixScaleArrayExpression(builderRoot),\n                \"inverted-tens-scale-array\" => CreateInvertedTensScaleArrayExpression(builderRoot),\n                \"indian-scale-form-array\" => CreateIndianScaleFormArrayExpression(builderRoot),\n                \"south-slavic-scale-array\" => CreateSouthSlavicScaleArrayExpression(builderRoot),\n                \"scale-leading-compound-scale-array\" => CreateScaleLeadingCompoundScaleArrayExpression(builderRoot),\n                \"scandinavian-scale-array\" => CreateScaleStrategyScaleArrayExpression(builderRoot),\n                \"unit-leading-compound-scale-array\" => CreateUnitLeadingCompoundScaleArrayExpression(builderRoot),\n                \"conjoined-gendered-scale-array\" => CreateConjoinedGenderedScaleArrayExpression(builderRoot),\n                \"segmented-scale-array\" => CreateSegmentedScaleArrayExpression(builderRoot),\n                \"stemmed-scale-array\" => CreateStemmedScaleArrayExpression(builderRoot),\n                \"linked-vigesimal-scale-array\" => CreateLinkedVigesimalScaleArrayExpression(builderRoot),\n                \"terminal-ordinal-scale-array\" => CreateTerminalOrdinalScaleArrayExpression(builderRoot),\n                \"construct-state-scale-array\" => CreateConstructStateScaleArrayExpression(builderRoot),\n                \"hyphenated-scale\" => CreateHyphenatedScaleExpression(builderRoot),\n                \"hyphenated-scale-array\" => CreateHyphenatedScaleArrayExpression(builderRoot),","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/NumberToWordsEngineContractFactory.cs#L492-L528","documentation":"The builder name 'east-asian-scale-array' is explicitly registered as a throw in the builder switch. This is an intentional guard: east-asian scale words are handled exclusively by the AddEngineMetricScaleWords path for the 'east-asian-grouped' engine, not through the generic builder pipeline. If a contract member references this builder, it signals a misconfiguration.","triggerScenarios":"An EngineContractMember is constructed with builder='east-asian-scale-array' and the builder dispatch reaches line 510. The switch arm unconditionally throws InvalidOperationException. This indicates the builder was referenced from a contract definition where it should never appear.","commonSituations":"Copy-pasting builder names from a reference list without checking which are engine-internal. Attempting to use east-asian scale words through a builder contract instead of the dedicated engine path. Misunderstanding the east-asian-grouped engine architecture.","solutions":["Remove the 'east-asian-scale-array' builder from the contract member — east-asian scales are auto-projected by the 'east-asian-grouped' engine in AddEngineMetricScaleWords.","If the locale uses the 'east-asian-grouped' engine, ensure its scale words are defined via smallUnitWords and largeUnits in the YAML, not through a builder contract.","If you need a different scale builder, choose one from the supported list (e.g., 'hyphenated-scale-array', 'segmented-scale-array')."],"exampleFix":"// before\nnew EngineContractMember(\n    kind: \"builder\",\n    sourcePath: \"scales\",\n    builder: \"east-asian-scale-array\",\n    ...)\n// after — remove this member; east-asian-grouped engine handles scales directly\n// (delete the EngineContractMember entirely from the contract's Members array)","handlingStrategy":"validation","validationCode":"// Validate that no contract member uses the guarded east-asian-scale-array builder:\nforeach (var m in contract.Members)\n    if (m.Builder == \"east-asian-scale-array\")\n        throw new ArgumentException(\n            \"east-asian-scale-array is engine-internal; use the east-asian-grouped engine path instead.\");","typeGuard":"static bool IsBuilderAllowed(EngineContractMember m) =>\n    m.Builder != \"east-asian-scale-array\";","tryCatchPattern":null,"preventionTips":["Never use 'east-asian-scale-array' as a builder name in contract definitions.","Understand that east-asian scale words are projected by AddEngineMetricScaleWords for the 'east-asian-grouped' engine.","Document builder names that are engine-internal vs. contract-facing in the source generator docs."],"tags":["source-generator","number-to-words","contract","builder","east-asian","engine-contract","build-time"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}