{"record":{"id":"abf152f0c6d6d428","repo":"hasura/graphql-engine","slug":"unexpected-value-expecting-expected-kind-but","errorCode":null,"errorMessage":"Unexpected value: expecting {expected_kind:}, but found: {found:}","messagePattern":"Unexpected value: expecting (.+?), but found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/ir/src/error.rs","lineNumber":46,"sourceCode":"            }\n        }\n    }\n}\n\n#[allow(clippy::duplicated_attributes)] // suppress spurious warnings from Clippy\n#[derive(Error, Debug, Transitive)]\n#[transitive(from(json::Error, InternalError))]\n#[transitive(from(gql::normalized_ast::Error, InternalError))]\n#[transitive(from(InternalEngineError, InternalError))]\n#[transitive(from(InternalDeveloperError, InternalError))]\npub enum Error {\n    #[error(\"The global ID {encoded_value:} couldn't be decoded due to {decoding_error:}\")]\n    FailureDecodingGlobalId {\n        encoded_value: String,\n        decoding_error: String,\n    },\n\n    #[error(\"Unexpected value: expecting {expected_kind:}, but found: {found:}\")]\n    UnexpectedValue {\n        expected_kind: &'static str,\n        found: json::Value,\n    },\n\n    #[error(\"'{name:}' is not a valid GraphQL name.\")]\n    TypeFieldInvalidGraphQlName { name: String },\n\n    #[error(\"'{alias:} is not a valid alias\")]\n    InvalidAlias { alias: String },\n\n    #[error(\"{value} is not a valid limit value\")]\n    InvalidLimitValue { value: u32 },\n\n    #[error(\"{value} is not a valid offset value\")]\n    InvalidOffsetValue { value: u32 },\n\n    #[error(\"field '{field_name:} not found in entity representation\")]","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/ir/src/error.rs#L28-L64","documentation":"The IR (intermediate representation) layer throws this when it encounters a JSON value whose kind doesn't match what the IR constructor expected at that position — e.g. a string where an object is required, or an array where a scalar is expected. The message names the expected kind and echoes the offending value, making it a structural validation error on incoming request data.","triggerScenarios":"Building IR values from request JSON: a where-clause argument, variable default, or entity representation field receives a JSON value of the wrong type (string given where number/object was expected).","commonSituations":"Clients sending loosely-typed variables (numbers as strings); schema/serialization drift between what the client sends and what the IR builder expects; hand-crafted JSON requests bypassing generated types.","solutions":["Inspect the 'found' value in the error and compare with the documented expected type for that argument/field","Fix the client to send correctly typed JSON (e.g. 42 not \"42\")","Add client-side schema validation (codegen, zod, etc.) so variables are type-checked before sending"],"exampleFix":"// before\nvariables: {{ filter: {{ count: \"10\" }} }}\n\n// after\nvariables: {{ filter: {{ count: 10 }} }}","handlingStrategy":"type-guard","validationCode":"if (typeof variables.filter?.count !== 'number') {\n  throw new TypeError('filter.count must be a number');\n}","typeGuard":"function isRecord(v: unknown): v is Record<string, unknown> {{\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}}","tryCatchPattern":"try {{\n  await execute(query, variables);\n}} catch (e: any) {{\n  if (e.message.includes('Unexpected value: expecting')) {{\n    // log variables, fix types, retry\n  }}\n}}","preventionTips":["Use generated types (graphql-codegen) for variables","Validate variable payloads with zod/io-ts before sending","Avoid coercing all values to strings in HTTP layers"],"tags":["graphql","ir","type-mismatch","json","validation","rust"],"backgroundTag":"value-type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}