{"record":{"id":"4c4003ab28560516","repo":"Humanizr/Humanizer","slug":"expected-json-array-or-mapping","errorCode":null,"errorMessage":"Expected JSON array or mapping.","messagePattern":"Expected JSON array or mapping\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs","lineNumber":1215,"sourceCode":"        builder.Append(\", \");\n        builder.Append(QuoteLiteral(GetRequiredString(objectElement, \"paucal\")));\n        builder.Append(\", \");\n        builder.Append(QuoteLiteral(GetRequiredString(objectElement, \"plural\")));\n\n        if (GetBoolean(objectElement, \"omitLeadingOne\"))\n        {\n            builder.Append(\", true\");\n        }\n\n        builder.Append(')');\n        return builder.ToString();\n    }\n\n    static string CreateInvertedTensTokenArrayExpression(JsonElement arrayElement)\n    {\n        if (arrayElement.ValueKind is not (JsonValueKind.Array or JsonValueKind.Object))\n        {\n            throw new InvalidOperationException(\"Expected JSON array or mapping.\");\n        }\n\n        var builder = new StringBuilder(\"new InvertedTensToken[] { \");\n        var first = true;\n\n        if (arrayElement.ValueKind == JsonValueKind.Object)\n        {\n            foreach (var (Name, Value) in arrayElement.EnumerateObject()\n                         .Select(static property =>\n                         {\n                             return property.Value.ValueKind != JsonValueKind.Number || !property.Value.TryGetInt64(out var value)\n                                 ? throw new InvalidOperationException($\"Inverted tens token '{property.Name}' must map to an integer value.\")\n                                 : (property.Name, Value: value);\n                         })\n                         .OrderByDescending(static entry => entry.Value)\n                         .ThenBy(static entry => entry.Name, StringComparer.Ordinal))\n            {\n                if (!first)","sourceCodeStart":1197,"sourceCodeEnd":1233,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs#L1197-L1233","documentation":"Thrown by the inverted-tens-scale-array builder when the YAML node is neither a JSON array nor a JSON object. The builder accepts two shapes (a sequence of rows or a mapping of token->integer), so any scalar, boolean, or null is rejected because it cannot be enumerated either way.","triggerScenarios":"A locale YAML provides a scalar (string or number) or null for an inverted-tens-scale-array section. The ValueKind pattern match 'is not (Array or Object)' catches it before iteration.","commonSituations":"Editing an inverted-tens locale (e.g. a Germanic-style inverted tens like 'einundzwanzig') and replacing the token map/list with a single quoted string. Appears as a CS8785 generator failure at build time.","solutions":["Convert the YAML value to either a sequence of mappings or a mapping of token name to integer value.","For the mapping form, each key is the token string and each value is an integer (e.g. einundzwanzig: 21).","Rebuild to confirm the generator accepts the corrected node."],"exampleFix":"# before\ninvertedTens: 'einundzwanzig'\n# after\ninvertedTens:\n  einundzwanzig: 21","handlingStrategy":"validation","validationCode":"// Confirm the inverted-tens node is a YAML sequence or mapping before\n// building. Scalars, booleans, and null are rejected.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inverted-tens builders accept a sequence or a token->integer mapping; never a scalar.","Build locally after locale edits to surface generator errors.","Model the structure on a known inverted-tens locale."],"tags":["source-generator","locale-yaml","configuration","build-time","humanizer"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}