{"record":{"id":"cbfb486151d3b52f","repo":"Humanizr/Humanizer","slug":"property-propertyname-must-be-a-string-array","errorCode":null,"errorMessage":"Property '{propertyName}' must be a string, array, or mapping (got {property.ValueKind}).","messagePattern":"Property '(.+?)' must be a string, array, or mapping \\(got (.+?)\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs","lineNumber":1015,"sourceCode":"            RequiredInt64Value(\"value\"),\n            BooleanValue(\"addSpaceBeforeNextPart\"),\n            OptionalEnumValue(\"countGender\", \"GrammaticalGender\", \"masculine\"),\n            RequiredStringValue(\"singularCardinal\"),\n            RequiredStringValue(\"pluralCardinalFormat\"),\n            static element => CreateUnitLeadingCompoundOrdinalPairExpression(element, \"ordinalSingular\"),\n            static element => CreateUnitLeadingCompoundOrdinalPairExpression(element, \"ordinalPlural\"),\n            OptionalStringValue(\"countWordFormNextWord\"));\n\n    static string CreateUnitLeadingCompoundOrdinalPairExpression(JsonElement element, string propertyName)\n    {\n        return !element.TryGetProperty(propertyName, out var property)\n            ? throw new InvalidOperationException($\"Missing required property '{propertyName}'.\")\n            : property.ValueKind switch\n            {\n                JsonValueKind.String => \"new string[] { \" + QuoteLiteral(property.GetString()!) + \", \" + QuoteLiteral(property.GetString()!) + \" }\",\n                JsonValueKind.Array => CreateStringArrayExpression(property),\n                JsonValueKind.Object => CreateTerminalContinuingStringArrayExpression(property, propertyName),\n                _ => throw new InvalidOperationException($\"Property '{propertyName}' must be a string, array, or mapping (got {property.ValueKind}).\")\n            };\n    }\n\n    static string CreateTerminalContinuingStringArrayExpression(JsonElement objectElement, string propertyName)\n    {\n        return objectElement.ValueKind != JsonValueKind.Object\n            ? throw new InvalidOperationException($\"Property '{propertyName}' must be a mapping.\")\n            : \"new string[] { \" +\n               QuoteLiteral(GetRequiredString(objectElement, \"terminal\")) + \", \" +\n               QuoteLiteral(GetRequiredString(objectElement, \"continuing\")) +\n               \" }\";\n    }\n\n    static string CreateConjoinedGenderedScaleArrayExpression(JsonElement arrayElement)\n        => CreateTypedConstructorArrayExpression(\n            \"ConjoinedGenderedScale\",\n            arrayElement,\n            RequiredInt64Value(\"divisor\"),","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs#L997-L1033","documentation":"Thrown by CreateUnitLeadingCompoundOrdinalPairExpression when an ordinalSingular or ordinalPlural property has an unsupported JSON value kind (not string, array, or object). The generator supports three shapes for an ordinal pair but rejects booleans, numbers, or null, because it cannot map them to the two-element string[] output.","triggerScenarios":"A locale YAML provides an ordinalSingular or ordinalPlural entry whose YAML value parses to a JSON number, boolean, or null rather than a scalar/sequence/mapping. The switch expression falls through to the default arm and throws, naming the property and the offending ValueKind.","commonSituations":"A contributor writes 'ordinalSingular: true' or 'ordinalSingular: 21' by mistake, or leaves a bare null. Less commonly, a YAML quoting slip turns a word into a number. Surfaces at build time via the source generator.","solutions":["Open the locale YAML and change the flagged ordinalSingular/ordinalPlural value to a quoted string, a sequence of strings, or a mapping with 'terminal' and 'continuing'.","If the word looks numeric, wrap it in quotes (e.g. 'ordinalSingular: \"21\"') so YAML treats it as a string.","Rebuild to confirm the generator accepts the corrected shape."],"exampleFix":"# before\nordinalSingular: 21\n# after\nordinalSingular: 'dwudziesty pierwszy'","handlingStrategy":"validation","validationCode":"# Ensure ordinal pair values are quoted strings, sequences, or mappings:\n#   rg \"ordinalSingular:|ordinalPlural:\" src/Humanizer/Locales/<code>.yml\n# No value should be a bare number, boolean, or null.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote any ordinal word that could be mistaken for a number (e.g. 'ordinalSingular: \"21\"').","Use only the three supported shapes: string, sequence, or terminal/continuing mapping.","Build locally after ordinal edits to catch kind mismatches."],"tags":["source-generator","locale-yaml","configuration","build-time","ordinal","humanizer"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}