hasura/graphql-engine · error · AggregateBooleanExpressionError

the operand object type '{operand_type}' does not contain th

Error message

the operand object type '{operand_type}' does not contain the field '{field_name}' used in the comparable fields

What it means

When resolving comparable fields, the operand object type is inspected for the referenced field. This error is thrown when the operand object type (a custom type qualified by name) does not contain the field used in the comparable fields list, meaning the comparison has no counterpart on the operand side.

Source

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

    },

    #[error("the order by expression '{order_by_expression}' could not be found")]
    OrderByExpressionNotFound {
        order_by_expression: Qualified<OrderByExpressionName>,
    },

    #[error("the field '{field_name}' is defined more than once in the comparable fields")]
    DuplicateComparableFieldsFound { field_name: FieldName },

    #[error(
        "the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'"
    )]
    ComparableFieldNotFound {
        field_name: FieldName,
        aggregate_expression: Qualified<AggregateExpressionName>,
    },

    #[error(
        "the operand object type '{operand_type}' does not contain the field '{field_name}' used in the comparable fields"
    )]
    ComparableFieldNotFoundOnObjectType {
        operand_type: Qualified<CustomTypeName>,
        field_name: FieldName,
    },

    #[error(
        "the type of the comparable field '{field_name}' ({field_type}) is an array type. Nested aggregation over array types is not supported"
    )]
    ComparableFieldNestedArrayTypeNotSupported {
        field_name: FieldName,
        field_type: QualifiedTypeReference,
    },

    #[error(
        "the boolean expression type ({boolean_expression_type}) used in the comparable field '{field_name}' could not be found"
    )]

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify the field exists on the operand object type in the current schema and fix the name in comparable_fields
  2. If the field was renamed, update comparable_fields (and the aggregate expression) accordingly
  3. Regenerate metadata from the current connector schema

Example fix

// before
comparable_fields: [price] // operand type has 'cost', not 'price'

// after
comparable_fields: [cost]  // matches operand object type field
Defensive patterns

Strategy: validation

Validate before calling

for f in &comparable_fields {
    assert!(operand_type.fields.contains(f), "operand type lacks field {f}");
}

Type guard

fn field_on_type(ty: &ObjectType, f: &FieldName) -> bool {
    ty.fields.contains(f)
}

Try / catch

match resolve(expr) {
    Err(ResolveError::ComparableFieldNotFoundOnObjectType { operand_type, field_name }) => {
        // fix field name to match the operand object type's schema and retry
    }
    r => r,
}

Prevention

When it happens

Trigger: A comparable field name that exists on the aggregate expression but not on the operand object type, e.g. after the object type's schema changed or the field naming differs between the aggregate and the operand type.

Common situations: Connector schema evolution removing/renaming a field on the operand object type; mismatched field naming conventions between aggregate fields and object type fields; metadata referencing a stale version of the object type.

Related errors


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