{"record":{"id":"89f605da36c1bb66","repo":"hasura/graphql-engine","slug":"nested-predicate-used-in-type-type-name","errorCode":null,"errorMessage":"Nested predicate used in type '{type_name:}'","messagePattern":"Nested predicate used in type '(.+?)'","errorType":"validation","errorClass":"TypePredicateError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/types/error.rs","lineNumber":471,"sourceCode":"        field_name: Spanned<FieldName>,\n        field_type: QualifiedTypeReference,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"field '{field_name}' of type '{type_name}' used in a field comparison is a predicate type and therefore cannot be compared to a single value\"\n    )]\n    UnsupportedFieldComparisonToPredicateType {\n        field_name: Spanned<FieldName>,\n        field_type: QualifiedTypeReference,\n        type_name: Qualified<CustomTypeName>,\n    },\n\n    #[error(\"Invalid operator used in type '{type_name:}' predicate: '{operator_name:}'\")]\n    InvalidOperatorInTypePredicate {\n        type_name: Qualified<CustomTypeName>,\n        operator_name: Spanned<OperatorName>,\n    },\n    #[error(\"Nested predicate used in type '{type_name:}'\")]\n    NestedPredicateInTypePredicate {\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"no boolean expression found for type '{type_name:}' This is required when filtering a nested field. Please ensure the model you are filtering has a filterExpressionType defined.\"\n    )]\n    NoBooleanExpressionFields {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"relationship '{relationship_name}' is used in predicate but does not exist for type '{type_name}'\"\n    )]\n    UnknownRelationshipInTypePredicate {\n        relationship_name: Spanned<RelationshipName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/types/error.rs#L453-L489","documentation":"A predicate for the given type contained a nested predicate where one was not allowed. The boolean expression type in question does not support nested sub-predicates at that position, so the resolver rejects the structure outright.","triggerScenarios":"Embedding a full predicate object inside a type predicate whose operator/field position only accepts scalar values or leaf expressions; deeply nested `_and`/`_or` structures beyond what the expression type models.","commonSituations":"Machine-generated filters that always wrap values in expression objects; converting flat filters to nested ones without updating the expression type; expression types that only define leaf operators.","solutions":["Flatten the predicate: the value at that position should be a leaf comparison, not another predicate","Extend the boolean expression type to support nested expressions if nesting is genuinely needed","Validate filter payload shapes against the expression type schema before sending"],"exampleFix":"// before\n{\"field\": \"age\", \"operator\": \"_eq\", \"value\": {\"operator\": \"_gt\", \"value\": 18}}\n// after\n{\"field\": \"age\", \"operator\": \"_gt\", \"value\": 18}\n","handlingStrategy":"validation","validationCode":"// Validate predicate shape: leaf positions must hold values, not nested predicates\nif is_leaf_position(&expr) && is_predicate(&expr.value) {\n    return Err(\"nested predicate not allowed here\".into());\n}","typeGuard":"fn is_nested_predicate(v: &PredicateValue) -> bool {\n    matches!(v, PredicateValue::Expression(_))\n}","tryCatchPattern":"if let Err(TypePredicateError::NestedPredicateInTypePredicate { type_name }) = result {\n    // flatten the predicate structure and retry\n}","preventionTips":["Validate filter payloads against the expression type schema (JSON Schema) before sending","Keep filter builders type-driven"],"tags":["filter","predicate","nested","hasura","metadata"],"backgroundTag":"invalid-filter-expression","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}