hasura/graphql-engine · error · AggregateBooleanExpressionError

could not find a scalar-operanded boolean expression type na

Error message

could not find a scalar-operanded boolean expression type named '{boolean_expression_type}'

What it means

Thrown by the metadata-resolve stage for aggregate boolean expressions when a filter references a boolean expression type (by name via BooleanExpressionTypeIdentifier) that does not exist in the resolved metadata. The resolver walks the boolean expression types declared on the target type/subgraph and fails to find one matching the referenced name, so the aggregate filter cannot be type-checked.

Source

Thrown at v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs:176

        aggregate_operand: QualifiedTypeName,
    },

    #[error(
        "the aggregate function '{aggregation_function_name}' is defined more than once in the comparable aggregation functions"
    )]
    DuplicateAggregationFunctionFound {
        aggregation_function_name: AggregationFunctionName,
    },

    #[error(
        "the aggregation function '{aggregation_function_name}' is not defined in the aggregate expression '{aggregate_expression}'"
    )]
    AggregationFunctionNotFound {
        aggregation_function_name: AggregationFunctionName,
        aggregate_expression: Qualified<AggregateExpressionName>,
    },

    #[error(
        "could not find a scalar-operanded boolean expression type named '{boolean_expression_type}'"
    )]
    ScalarBooleanExpressionTypeNotFound {
        boolean_expression_type: BooleanExpressionTypeIdentifier,
    },

    #[error(
        "type mismatch between the aggregation function '{aggregation_function_name}' (return type: '{aggregation_function_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')"
    )]
    AggregationFunctionTypeMismatch {
        aggregation_function_name: AggregationFunctionName,
        aggregation_function_return_type: QualifiedTypeName,
        boolean_expression_type: BooleanExpressionTypeIdentifier,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error(
        "the aggregation function '{aggregation_function_name}' returns an array type ({aggregation_function_return_type}). Array types are not supported in aggregate comparisons"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify the boolean expression type name referenced in the failing metadata exists in the same subgraph/metadata
  2. Check for renames or removals of boolean_expression_type entries in recent metadata changes and update references
  3. Run metadata consistency checks (metadata validate) to list all dangling named-type references
  4. If the type was intentionally removed, remove the aggregate filter/field that references it

Example fix

// before
filter:
  _bool_exp: MissingBoolExpType  # not defined on operand type

// after
filter:
  _bool_exp: ExistingBoolExpType # defined in boolean_expression_types
Defensive patterns

Strategy: validation

Validate before calling

// before applying metadata, assert the boolean expression type exists
let defined: HashSet<_> = operand_type.boolean_expression_types.iter().collect();
assert!(defined.contains(&referenced_bool_exp_type),
    "boolean expression type {referenced_bool_exp_type} not defined on operand");

Type guard

fn bool_exp_exists(meta: &Metadata, name: &BooleanExpressionTypeIdentifier) -> bool {
    meta.boolean_expression_types.iter().any(|t| t.name == *name)
}

Try / catch

match resolve(expr) {
    Err(ResolveError::ScalarBooleanExpressionTypeNotFound { boolean_expression_type }) => {
        eprintln!("unknown boolean expression type: {boolean_expression_type}");
        // surface to user or skip field
    }
    r => r,
}

Prevention

When it happens

Trigger: Using an aggregate boolean expression (e.g. _bool_exp on an aggregate or filtered aggregate field) whose filter names a scalar-operanded boolean expression type that is not defined on the operand type, or renaming/removing a boolean expression type in the metadata while other metadata still references the old name.

Common situations: Renaming or deleting a custom boolean_expression_type in the metadata while a comparative_aggregate or aggregate filter still uses the old name; copy-pasting metadata between environments where the named type is absent; typos in the boolean expression type name in ndc/connector metadata.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/667523fe55e24470. Report an issue: GitHub.