{"record":{"id":"6d01b17b9941b102","repo":"hasura/graphql-engine","slug":"typecasting-session-variable-session-variable-to","errorCode":null,"errorMessage":"Typecasting session variable {session_variable} to an array is not supported. Update your compatibility date to enable JSON session variables","messagePattern":"Typecasting session variable (.+?) to an array is not supported\\. Update your compatibility date to enable JSON session variables","errorType":"validation","errorClass":"InternalDeveloperError","httpStatus":null,"severity":"error","filePath":"v3/crates/plan/src/error.rs","lineNumber":54,"sourceCode":"    },\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    )]\n    VariableExpectedJson {\n        session_variable: SessionVariableName,\n        parse_error: serde_json::Error,\n    },\n\n    #[error(\"Type mapping not found for the type name {type_name:}\")]\n    TypeMappingNotFound {\n        type_name: Qualified<CustomTypeName>,\n    },","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plan/src/error.rs#L36-L72","documentation":"The plan crate was asked to typecast a session variable to an array, but the project's compatibility date does not include JSON session variable support, so non-string (array) session variables cannot be produced.","triggerScenarios":"An expression contains a cast of a session variable to an array type while running with an older compatibility date; the cast is rejected before execution.","commonSituations":"Using array-typed presets fed by session variables on a project created before JSON session variables existed; upgrading the engine but keeping the old compatibility date constant.","solutions":["Update the compatibility date so JSON session variables (and array casts) are enabled","Or replace the array session variable with a string-encoded value parsed elsewhere","Or stop casting that variable to an array and derive the array inside the query instead"],"exampleFix":"# before\ncompatibility_date: \"2024-01-01\"   # preset casts session var to array\n# after\ncompatibility_date: \"2025-01-01\"   # array casts of session vars allowed","handlingStrategy":"validation","validationCode":"// Guard array casts behind a feature check before building the query\nif expr_casts_session_var_to_array(&plan) && compatibility_date < JSON_SESSION_VARS_DATE {\n    return Err(\"array cast of session variable requires newer compatibility date\");\n}","typeGuard":null,"tryCatchPattern":"match err {\n    InternalDeveloperError::VariableArrayTypeCastNotSupported { .. } => {\n        // bump compatibility date or string-encode the value\n    }\n    _ => {}\n}","preventionTips":["Review compatibility-date-gated features when upgrading the engine","Avoid array session variables unless the transport guarantees JSON support"],"tags":["session-variables","compatibility-date","typecast","hasura"],"backgroundTag":"compatibility-date-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}