{"record":{"id":"2f17067e582f7412","repo":"JamesNK/Newtonsoft.Json","slug":"properties-0-not-valid-on-1","errorCode":null,"errorMessage":"Properties {0} not valid on {1}.","messagePattern":"Properties (.+?) not valid on (.+?)\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs","lineNumber":46,"sourceCode":"                    {\n                        JToken? v = o[name];\n\n                        if (v != null)\n                        {\n                            yield return v;\n                        }\n\n                        if (settings?.ErrorWhenNoMatch ?? false)\n                        {\n                            throw new JsonException(\"Property '{0}' does not exist on JObject.\".FormatWith(CultureInfo.InvariantCulture, name));\n                        }\n                    }\n                }\n                else\n                {\n                    if (settings?.ErrorWhenNoMatch ?? false)\n                    {\n                        throw new JsonException(\"Properties {0} not valid on {1}.\".FormatWith(CultureInfo.InvariantCulture, string.Join(\", \", Names.Select(n => \"'\" + n + \"'\")\n#if !HAVE_STRING_JOIN_WITH_ENUMERABLE\n                            .ToArray()\n#endif\n                            ), t.GetType().Name));\n                    }\n                }\n            }\n        }\n    }\n}","sourceCodeStart":28,"sourceCodeEnd":56,"githubUrl":"https://github.com/JamesNK/Newtonsoft.Json/blob/4f73e74372445108d2c1bda37b36e6f5e43402e0/Src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs#L28-L56","documentation":"Thrown during JSONPath evaluation when a multiple-field filter (e.g. $['a','b']) is applied to a token that is not a JObject, and ErrorWhenNoMatch is true. FieldMultipleFilter can only read properties off objects; a JArray, JValue, or JProperty triggers the error, listing all requested property names and the actual token type.","triggerScenarios":"Calling SelectTokens(\"$.data['x','y']\", errorWhenNoMatch: true) where 'data' resolves to a JArray or scalar rather than a JObject. The non-object branch (FieldMultipleFilter.cs:44-51) fires.","commonSituations":"Schema drift where an object became a list; indexing multiple properties off a value that is actually an array; a polymorphic response returning different shapes per record.","solutions":["Confirm the target token is a JObject before applying a multi-field indexer.","Drop errorWhenNoMatch so a non-object target yields zero results.","Add the correct array indexing step before the property access."],"exampleFix":"// before\ntoken.SelectTokens(\"$.data['x','y']\", errorWhenNoMatch: true); // data is a JArray\n\n// after\ntoken.SelectTokens(\"$.data[0]['x','y']\", errorWhenNoMatch: false);","handlingStrategy":"type-guard","validationCode":"var node = token[\"data\"];\nif (node is JObject obj)\n{\n    var vals = obj.SelectTokens(\"['x','y']\");\n}","typeGuard":"static bool IsJsonObject(JToken? t) => t is JObject;","tryCatchPattern":null,"preventionTips":["Verify the target is a JObject before a multi-field access.","Keep errorWhenNoMatch off for multi-field queries.","Add array indexing steps when the target is actually a list."],"tags":["jsonpath","type-mismatch","multi-field"],"analyzedSha":"4f73e74372445108d2c1bda37b36e6f5e43402e0","analyzedAt":"2026-08-07T06:10:08.596Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}