{"record":{"id":"6a33b262b2bd26f8","repo":"hasura/graphql-engine","slug":"serde-error-error","errorCode":null,"errorMessage":"Serde error: {error}","messagePattern":"Serde error: (.+?)","errorType":"error_code","errorClass":"ConditionError","httpStatus":null,"severity":"error","filePath":"v3/crates/auth/authorization-rules/src/condition.rs","lineNumber":17,"sourceCode":"//! this is where we evaluate Conditions\n\nuse std::fmt::Display;\n\nuse hasura_authn_core::{SessionVariableName, SessionVariables};\n\nuse crate::ConditionCache;\nuse metadata_resolve::{\n    BinaryOperation, Condition, ConditionHash, Conditions, UnaryOperation, ValueExpression,\n};\nuse open_dds::query::ArgumentName;\n\n#[derive(Debug, PartialEq, Eq, thiserror::Error)]\npub enum ConditionError {\n    #[error(\"Session variable not found: {name}\")]\n    SessionVariableNotFound { name: SessionVariableName },\n    #[error(\"Serde error: {error}\")]\n    SerdeError { error: String },\n    #[error(\"Condition {condition_hash} not found\")]\n    ConditionNotFound { condition_hash: ConditionHash },\n    #[error(\"Expected array or null for right-hand value of contains operation\")]\n    ExpectedArrayOrNullForContains,\n    #[error(\"Expected number for {side}-hand value of comparison operation\")]\n    ExpectedNumberForComparison { side: Side },\n    #[error(\n        \"Number for {side}-hand value of comparison operation is outside precision or range of a double-precision float\"\n    )]\n    NumberOutOfRange { side: Side },\n    #[error(\n        \"Tried to combine a predicate with a literal in argument presets for argument {argument_name}\"\n    )]\n    CouldNotCombinePredicateAndLiteralArgumentPresets { argument_name: ArgumentName },\n}\n\n// evaluate conditions used in permissions","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/auth/authorization-rules/src/condition.rs#L1-L35","documentation":"A generic wrapper in the authorization condition evaluator: any (de)serialization failure while parsing/evaluating parts of a permission condition — e.g. deserializing an argument name, expression tree, or comparison value that doesn't match the expected IR shape — is surfaced as ConditionError::SerdeError with the underlying error string.","triggerScenarios":"Metadata containing a comparison/expression value whose JSON shape doesn't deserialize into the condition IR: wrong type for an operand, malformed expression objects, or version-skewed metadata generated by a different CLI/engine version.","commonSituations":"Hand-edited or tool-generated metadata with subtly wrong shapes; upgrading the platform so condition IR schemas changed while old metadata remains; passing complex objects where scalars are expected in rules.","solutions":["Read the embedded `{error}` string — it names the exact field and expected type","Validate/re-apply role permission metadata with the current CLI version (hasura metadata apply / build)","Regenerate the metadata rather than hand-editing condition expressions","Check for version skew between the CLI that produced the metadata and the engine evaluating it"],"exampleFix":"# before\ncomparison_expressions:\n  - name: by_user\n    expression: { column: user_id, value: { session: x_hasura_user_id } }\n# after (match the documented IR shape)\ncomparison_expressions:\n  - name: by_user\n    expression:\n      and:\n        - { column: user_id, operator: eq, value: { session: x_hasura_user_id } }","handlingStrategy":"try-catch","validationCode":"// Validate metadata against the project's schema before apply\n// e.g. hasura3 metadata export + CI JSON-schema check of comparison expressions","typeGuard":"null","tryCatchPattern":"match cond_eval { Err(ConditionError::SerdeError { error }) => { log::warn!(\"bad condition shape: {error}\"); deny_or_fix() } _ => ... }","preventionTips":["Generate metadata with the current CLI; avoid hand-editing IR","Validate metadata files in CI before apply","Upgrade CLI and engine together"],"tags":["auth","authorization","serde","metadata","deserialization","rust"],"backgroundTag":"metadata-deserialization-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}