{"record":{"id":"92ef1fcb0670344a","repo":"hasura/graphql-engine","slug":"failed-to-convert-session-variable-variable-name","errorCode":null,"errorMessage":"Failed to convert session variable '{variable_name}': {error}","messagePattern":"Failed to convert session variable '(.+?)': (.+?)","errorType":"validation","errorClass":"BuildRequestError","httpStatus":null,"severity":"error","filePath":"v3/crates/plugins/pre-ndc-request-plugin/src/execute.rs","lineNumber":54,"sourceCode":"}\n\n#[derive(Debug, thiserror::Error)]\npub enum BuildRequestError {\n    #[error(\"Invalid header name {header_name}: {error}\")]\n    InvalidHeaderName {\n        header_name: String,\n        #[source]\n        error: InvalidHeaderName,\n    },\n    #[error(\"Invalid header value for header {header_name}: {error}\")]\n    InvalidHeaderValue {\n        header_name: HeaderName,\n        #[source]\n        error: InvalidHeaderValue,\n    },\n    #[error(\"Failed to convert session: {0}\")]\n    SessionConversionError(String),\n    #[error(\"Failed to convert session variable '{variable_name}': {error}\")]\n    SessionVariableConversionError {\n        variable_name: SessionVariableName,\n        error: serde_json::Error,\n    },\n    #[error(\"Serialization error: {0}\")]\n    SerializationError(#[from] serde_json::Error),\n}\n\nimpl TraceableError for Error {\n    fn visibility(&self) -> ErrorVisibility {\n        match self {\n            Error::BuildRequestError(_, _) => ErrorVisibility::Internal,\n            Error::PluginUserError { .. }\n            | Error::ReqwestError(_)\n            | Error::PluginRequestParseError(_)\n            | Error::ErrorWhileMakingHTTPRequestToTheHook(_, _)\n            | Error::UnexpectedStatusCode(_)\n            | Error::PluginInternalError { .. } => ErrorVisibility::User,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plugins/pre-ndc-request-plugin/src/execute.rs#L36-L72","documentation":"One specific session variable could not be converted (typically serialized or coerced) while building the pre-NDC-request plugin call. The variable name is included along with the serde error, so you can pinpoint exactly which claim/value is malformed. This is narrower than SessionConversionError: a single variable's value does not fit its target type.","triggerScenarios":"A session variable named in plugin config exists in the session but its JSON value cannot serialize/deserialize into the type the plugin wire format requires, e.g. an object where a string is expected.","commonSituations":"IdP changes a claim from string to array/object (e.g. 'roles' becoming a list); forwarding a nested object into a slot the plugin expects as a scalar; stale plugin config referencing renamed claims.","solutions":["Check the named variable's actual value in your JWT/session and its expected type in plugin config","Fix the claim shape on the IdP side or update the plugin config to match the new shape","Remove the variable from forwarding if the plugin no longer needs it","Re-deploy engine and plugin together after schema changes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify claim type before enabling forwarding\nassert!(matches!(claims.get(\"roles\"), Some(serde_json::Value::Array(_))));","typeGuard":null,"tryCatchPattern":"if let Err(Error::SessionVariableConversionError { variable_name, .. }) = res {\n    tracing::warn!(variable_name, \"session variable type mismatch\");\n}","preventionTips":["Pin claim shapes in token templates","Remove config entries for claims you no longer issue"],"tags":["rust","session","auth","serde","plugin"],"backgroundTag":"session-variable-conversion-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}