hasura/graphql-engine · error · AggregateBooleanExpressionError

the aggregate expression '{aggregate_expression}' could not

Error message

the aggregate expression '{aggregate_expression}' could not be found

What it means

AggregateBooleanExpressionError::AggregateExpressionNotFound: the aggregate boolean expression references a qualified aggregate expression name that cannot be found in the resolved metadata. The missing qualified name is included in the message.

Source

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

    AggregateBooleanExpressionsNotSupported,

    #[error("boolean expressions with aggregate operands do not support isNull comparisons")]
    IsNullComparisonsNotSupported,

    #[error("{0}")]
    GraphqlConfigError(#[from] GraphqlConfigError),

    #[error("the operand type '{operand_type}' must be a scalar type")]
    OperandTypeIsNotAScalarType {
        operand_type: Qualified<CustomTypeName>,
    },

    #[error("the operand type '{operand_type}' must be an object type")]
    OperandTypeIsNotAnObjectType {
        operand_type: Qualified<CustomTypeName>,
    },

    #[error("the aggregate expression '{aggregate_expression}' could not be found")]
    AggregateExpressionNotFound {
        aggregate_expression: Qualified<AggregateExpressionName>,
    },

    #[error(
        "the operand type '{operand_type}' does not match the operand type '{aggregate_operand}' from the aggregate expression '{aggregate_expression}'"
    )]
    AggregateOperandTypeMismatch {
        operand_type: QualifiedTypeName,
        aggregate_expression: Qualified<AggregateExpressionName>,
        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,

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check the spelling and subgraph of the aggregate_expression reference
  2. Define the missing aggregate expression in metadata
  3. If it lives in another subgraph, reference the correct qualified name or move the definition

Example fix

# before
aggregate_expression: orders.MeanOrderValue   # not defined

# after
aggregate_expression: analytics.MeanOrderValue   # correct subgraph
Defensive patterns

Strategy: validation

Validate before calling

fn aggregate_expression_exists(metadata: &Metadata, name: &Qualified<AggregateExpressionName>) -> bool {
    metadata.aggregate_expressions.contains_key(name)
}

Try / catch

if let AggregateBooleanExpressionError::AggregateExpressionNotFound { aggregate_expression } = err {
    eprintln!("define or fix reference to {aggregate_expression:?}");
}

Prevention

When it happens

Trigger: Using an aggregate_expression reference (subgraph + AggregateExpressionName) that was never defined, is defined in another subgraph, or is misspelled.

Common situations: Deleting or renaming an aggregate expression without updating references, cross-subgraph references that aren't imported, typos in qualified names.

Related errors


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