{"record":{"id":"6abef66c15bb3d85","repo":"hasura/graphql-engine","slug":"session-variable-session-variable-value-is-of-an","errorCode":null,"errorMessage":"Session variable {session_variable} value is of an unexpected type. Expected: {expected}, but found: {found}","messagePattern":"Session variable (.+?) value is of an unexpected type\\. Expected: (.+?), but found: (.+?)","errorType":"validation","errorClass":"InternalDeveloperError","httpStatus":null,"severity":"error","filePath":"v3/crates/plan/src/error.rs","lineNumber":45,"sourceCode":"        }\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum InternalDeveloperError {\n    #[error(\"Required session variable not found in the request: {session_variable}\")]\n    MissingSessionVariable {\n        session_variable: SessionVariableName,\n    },\n\n    #[error(\n        \"The session variables {session_variable} is not encoded as a string. JSON-typed session variables are not supported unless you update your compatibility date\"\n    )]\n    VariableJsonNotSupported {\n        session_variable: SessionVariableName,\n    },\n\n    #[error(\n        \"Session variable {session_variable} value is of an unexpected type. Expected: {expected}, but found: {found}\"\n    )]\n    VariableTypeCast {\n        session_variable: SessionVariableName,\n        expected: String,\n        found: String,\n    },\n\n    #[error(\n        \"Typecasting session variable {session_variable} to an array is not supported. Update your compatibility date to enable JSON session variables\"\n    )]\n    VariableArrayTypeCastNotSupported {\n        session_variable: SessionVariableName,\n    },\n\n    #[error(\n        \"Expected session variable {session_variable} to be a valid JSON value, but encountered a JSON parsing error: {parse_error}\"\n    )]","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plan/src/error.rs#L27-L63","documentation":"A session variable value could not be interpreted as the expected type during typecasting in the plan crate. The error names the variable, the expected type, and what was actually found (e.g. expected 'integer', found 'boolean').","triggerScenarios":"Typecasting a session variable (session_variable cast in an expression/preset) where the raw string/JSON value does not parse as the declared target type — e.g. x-hasura-role used as an integer, or a JSON array where a scalar was expected once JSON vars are enabled.","commonSituations":"Clients sending unquoted numbers/booleans in headers; presets casting x-hasura-* headers to int/float/date; mismatch between declared scalar type and what the auth webhook/JWT claim provides.","solutions":["Check the expected/found pair in the message and fix the client to send a value matching the expected type","Adjust the cast target type in the preset/expression to match the actual variable format","If the variable arrives as JSON, ensure the compatibility date and transport support it and that a scalar (not array/object) is provided"],"exampleFix":"# before\n# preset: count = session(x-hasura-count) :: integer  (client sends \"true\")\n# after\n# client sends: x-hasura-count: 42","handlingStrategy":"validation","validationCode":"// Pre-validate a castable value on the client\nfn parses_as(value: &str, ty: &str) -> bool {\n    match ty {\n        \"integer\" => value.parse::<i64>().is_ok(),\n        \"float\" => value.parse::<f64>().is_ok(),\n        \"boolean\" => value == \"true\" || value == \"false\",\n        _ => true,\n    }\n}","typeGuard":null,"tryCatchPattern":"match err {\n    InternalDeveloperError::VariableTypeCast { session_variable, expected, found } => {\n        eprintln!(\"{session_variable}: send {expected}, got {found}\");\n    }\n    _ => {}\n}","preventionTips":["Always send x-hasura-* header values as strings matching the declared type","Add contract tests for session-variable-driven presets"],"tags":["session-variables","typecast","plan","hasura"],"backgroundTag":"type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}