hasura/graphql-engine · error · AggregateBooleanExpressionError

the field '{field_name}' is defined more than once in the co

Error message

the field '{field_name}' is defined more than once in the comparable fields

What it means

Comparable fields lists in aggregate boolean expression metadata must name each field at most once. This error is raised during resolution when the same FieldName appears more than once in the comparable fields collection, which would make the comparison ambiguous.

Source

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

        boolean_expression_type: BooleanExpressionTypeIdentifier,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error(
        "the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'"
    )]
    FilterInputFilterExpressionTypeMismatch {
        operand_type: QualifiedTypeName,
        boolean_expression_type: Qualified<CustomTypeName>,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[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,
    },

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Deduplicate the comparable fields list so each field name appears once
  2. If the duplication comes from a merge conflict, resolve it by keeping a single entry
  3. Add a lint/CI check that validates uniqueness of comparable field names before applying metadata

Example fix

// before
comparable_fields: [price, rating, price]

// after
comparable_fields: [price, rating]
Defensive patterns

Strategy: validation

Validate before calling

let mut seen = HashSet::new();
for f in &comparable_fields {
    assert!(seen.insert(f.clone()), "duplicate comparable field: {f}");
}

Type guard

fn no_duplicates(fields: &[FieldName]) -> bool {
    let mut s = HashSet::new();
    fields.iter().all(|f| s.insert(f.clone()))
}

Try / catch

match resolve(expr) {
    Err(ResolveError::DuplicateComparableFieldsFound { field_name }) => {
        // deduplicate comparable_fields and re-apply metadata
    }
    r => r,
}

Prevention

When it happens

Trigger: Declaring comparable_fields on an aggregate expression where the same field name is listed twice, e.g. via duplicate entries or overlapping generated-plus-manual configuration.

Common situations: Merge conflicts in metadata YAML/JSON producing duplicated list entries; appending fields programmatically without deduplication; generated metadata being edited by hand and accidentally duplicating an entry.

Related errors


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