{"record":{"id":"8b906ebe27a80e0f","repo":"hasura/graphql-engine","slug":"value-did-not-match-object-type-was-expecting-ex","errorCode":null,"errorMessage":"Value did not match object type, was expecting {expected_type}","messagePattern":"Value did not match object type, was expecting (.+?)","errorType":"validation","errorClass":"MapFieldNamesError","httpStatus":null,"severity":"error","filePath":"v3/crates/plan/src/query/arguments.rs","lineNumber":649,"sourceCode":"                }\n            }\n            UnresolvedArgument::Literal { value } => Argument::Literal {\n                value: value.clone(),\n            },\n        };\n        resolved_arguments.insert(argument_name, resolved_argument_value.clone());\n    }\n\n    Ok(resolved_arguments)\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum MapFieldNamesError {\n    #[error(\"Value did not match array type, was expecting {expected_type}\")]\n    ExpectedAnArray {\n        expected_type: QualifiedTypeReference,\n    },\n    #[error(\"Value did not match object type, was expecting {expected_type}\")]\n    ExpectedAnObject {\n        expected_type: QualifiedTypeReference,\n    },\n    #[error(\"Type mappings not found for object type {object_type_name}\")]\n    TypeMappingsNotFound {\n        object_type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\"Field mapping {field_name} not found for object type {object_type_name}\")]\n    FieldMappingNotFound {\n        object_type_name: Qualified<CustomTypeName>,\n        field_name: FieldName,\n    },\n    #[error(\"Unknown fields found in object type {object_type_name}: {fields:?}\")]\n    UnknownFieldsInObject {\n        object_type_name: Qualified<CustomTypeName>,\n        fields: Vec<String>,\n    },\n}","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plan/src/query/arguments.rs#L631-L667","documentation":"MapFieldNamesError::ExpectedAnObject is raised when the argument field-name mapper expects an object/struct-shaped value (per the schema's QualifiedTypeReference) but the actual value is a scalar, array, or otherwise non-object JSON value. The mapper needs an object so it can rename fields per the NDC field mappings, so a non-object value at that position aborts planning.","triggerScenarios":"Passing a scalar or array where the schema declares an object input type for a command/model argument, e.g. {\"where\": 5} or {\"filter\": [\"a\"]} instead of {\"where\": {\"id\": {...}}}.","commonSituations":"Flattening or simplifying input objects on the client; sending JSON-encoded strings instead of nested objects; schema evolution turning a scalar argument into an object type; misunderstanding nested input type syntax in GraphQL variables.","solutions":["Send a JSON object (with the correct field names) wherever the schema declares an object input type","Compare the value's shape against the argument's input type in the schema/introspection","Fix client variable serialization that stringifies nested objects (JSON.stringify applied at the wrong level)","Update the schema type mapping if the object type is new and unmapped"],"exampleFix":"// before\nvariables: { \"where\": \"{\\\"id\\\":1}\" }\n// after\nvariables: { \"where\": { \"id\": 1 } }","handlingStrategy":"validation","validationCode":"fn assert_object_arg(name: &str, v: &serde_json::Value) -> Result<(), String> {\n    v.as_object().map(|_| ()).ok_or_else(|| format!(\"argument '{name}' must be an object\"))\n}","typeGuard":"const isJSONObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":"Catch MapFieldNamesError::ExpectedAnObject and surface expected_type in a client-facing validation error.","preventionTips":["Never pre-stringify nested variable objects","Use typed codegen for input objects","Add unit tests for nested argument shapes"],"tags":["rust","graphql","query-planning","arguments","type-mismatch"],"backgroundTag":"argument-type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}