{"record":{"id":"3cda6d45b536c2a5","repo":"hasura/graphql-engine","slug":"the-field-field-name-is-defined-more-than-once","errorCode":null,"errorMessage":"the field '{field_name}' is defined more than once in the comparable fields","messagePattern":"the field '(.+?)' is defined more than once in the comparable fields","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":233,"sourceCode":"        boolean_expression_type: BooleanExpressionTypeIdentifier,\n        boolean_expression_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\n        \"the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'\"\n    )]\n    FilterInputFilterExpressionTypeMismatch {\n        operand_type: QualifiedTypeName,\n        boolean_expression_type: Qualified<CustomTypeName>,\n        boolean_expression_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\"the order by expression '{order_by_expression}' could not be found\")]\n    OrderByExpressionNotFound {\n        order_by_expression: Qualified<OrderByExpressionName>,\n    },\n\n    #[error(\"the field '{field_name}' is defined more than once in the comparable fields\")]\n    DuplicateComparableFieldsFound { field_name: FieldName },\n\n    #[error(\n        \"the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'\"\n    )]\n    ComparableFieldNotFound {\n        field_name: FieldName,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n    },\n\n    #[error(\n        \"the operand object type '{operand_type}' does not contain the field '{field_name}' used in the comparable fields\"\n    )]\n    ComparableFieldNotFoundOnObjectType {\n        operand_type: Qualified<CustomTypeName>,\n        field_name: FieldName,\n    },\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L215-L251","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Deduplicate the comparable fields list so each field name appears once","If the duplication comes from a merge conflict, resolve it by keeping a single entry","Add a lint/CI check that validates uniqueness of comparable field names before applying metadata"],"exampleFix":"// before\ncomparable_fields: [price, rating, price]\n\n// after\ncomparable_fields: [price, rating]","handlingStrategy":"validation","validationCode":"let mut seen = HashSet::new();\nfor f in &comparable_fields {\n    assert!(seen.insert(f.clone()), \"duplicate comparable field: {f}\");\n}","typeGuard":"fn no_duplicates(fields: &[FieldName]) -> bool {\n    let mut s = HashSet::new();\n    fields.iter().all(|f| s.insert(f.clone()))\n}","tryCatchPattern":"match resolve(expr) {\n    Err(ResolveError::DuplicateComparableFieldsFound { field_name }) => {\n        // deduplicate comparable_fields and re-apply metadata\n    }\n    r => r,\n}","preventionTips":["Deduplicate lists programmatically instead of hand-editing","Add a JSON Schema/lint rule enforcing unique comparable field entries"],"tags":["rust","metadata","duplicate","comparable-fields","validation"],"backgroundTag":null,"analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}