hasura/graphql-engine · error · AggregateBooleanExpressionError

the relationship '{relationship_name}' is defined more than

Error message

the relationship '{relationship_name}' is defined more than once in the comparable relationships

What it means

When collecting the comparable relationships for a boolean expression type's aggregation support, the same relationship name appears more than once. Duplicate declarations make the generated aggregation input ambiguous, so the resolver rejects them.

Source

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

    )]
    ComparableFieldBooleanExpressionIncorrectOperandType {
        boolean_expression_type: Qualified<CustomTypeName>,
        aggregate_operand_type: AggregateOperandType,
        field_name: FieldName,
        field_type: QualifiedTypeName,
    },

    #[error(
        "the type of the comparable field '{field_name}' ({field_type}) does not match the operand type of the boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'"
    )]
    ComparableFieldBooleanExpressionTypeMismatch {
        field_name: FieldName,
        field_type: QualifiedTypeName,
        boolean_expression_type: Qualified<CustomTypeName>,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error(
        "the relationship '{relationship_name}' is defined more than once in the comparable relationships"
    )]
    DuplicateComparableRelationshipsFound {
        relationship_name: open_dds::relationships::RelationshipName,
    },

    #[error(
        "the comparable relationship '{relationship_name}' was not found for the operand type '{operand_type}'"
    )]
    ComparableRelationshipNotFound {
        operand_type: Qualified<CustomTypeName>,
        relationship_name: RelationshipName,
    },

    #[error(
        "the comparable relationship '{relationship_name}' for the operand type '{operand_type}' targets a command. This is not supported"
    )]
    ComparableRelationshipCommandTargetNotSupported {

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Find the duplicated relationship_name in the comparable relationships list and remove or rename the duplicate
  2. Check YAML anchors/merge keys for accidental duplication
  3. If metadata is generated, fix the generator so it emits each comparable relationship exactly once

Example fix

# before
comparableRelationships:
  - relationshipName: author
  - relationshipName: author   # duplicate

# after
comparableRelationships:
  - relationshipName: author
  - relationshipName: reviews
Defensive patterns

Strategy: validation

Validate before calling

let names: HashSet<_> = comparable_relationships.iter().map(|r| &r.relationship_name).collect();
assert_eq!(names.len(), comparable_relationships.len(), "duplicate comparable relationship");

Prevention

When it happens

Trigger: Two comparable relationship entries in the metadata share the same RelationshipName for the same operand type (e.g. duplicated entries in a list of comparable relationships).

Common situations: Copy-pasting comparable relationship entries and forgetting to rename them; YAML merge keys or anchors accidentally duplicating entries; merging metadata from multiple files that both declare the same relationship as comparable.

Related errors


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