{"record":{"id":"1143a1b523884628","repo":"hasura/graphql-engine","slug":"type-mismatch-between-the-count-type-aggregate","errorCode":null,"errorMessage":"type mismatch between the '{count_type}' aggregate (return type: '{count_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')","messagePattern":"type mismatch between the '(.+?)' aggregate \\(return type: '(.+?)'\\) and the specified boolean expression type '(.+?)' \\(operand type: '(.+?)'\\)","errorType":"validation","errorClass":"AggregateBooleanExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs","lineNumber":209,"sourceCode":"    },\n\n    #[error(\n        \"the aggregation function '{aggregation_function_name}' returns an array type ({aggregation_function_return_type}). Array types are not supported in aggregate comparisons\"\n    )]\n    ComparisonAgainstArrayTypesNotSupported {\n        aggregation_function_name: AggregationFunctionName,\n        aggregation_function_return_type: QualifiedTypeReference,\n    },\n\n    #[error(\n        \"the {count_type} aggregation cannot be compared to because it is not enabled on the aggregate expression '{aggregate_expression}'\"\n    )]\n    CountAggregateNotEnabled {\n        count_type: CountAggregateType,\n        aggregate_expression: Qualified<AggregateExpressionName>,\n    },\n\n    #[error(\n        \"type mismatch between the '{count_type}' aggregate (return type: '{count_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')\"\n    )]\n    CountAggregateTypeMismatch {\n        count_type: CountAggregateType,\n        count_return_type: QualifiedTypeName,\n        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","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs#L191-L227","documentation":"Similar to the general aggregation-function mismatch, this variant applies to the built-in count aggregates: the resolved return type of the count aggregate must equal the operand type of the boolean expression type used in the comparison. Count aggregates can be typed differently (e.g. Int vs BigInt vs custom count types), and a mismatch triggers this error.","triggerScenarios":"Comparing a count aggregate whose return type is a custom/BigInt scalar against a boolean expression type whose operand is a different scalar (e.g. Int); changing the configured count return type in connector capabilities without regenerating dependent boolean expression types.","commonSituations":"Connectors defining custom count scalar types (e.g. BigInt) while metadata compares using Int-typed expressions; upgrading a connector that changes the count aggregate's scalar type; mixing hand-written and generated metadata.","solutions":["Use a boolean expression type whose operand type matches the count aggregate's declared return type","Align the connector's count scalar type with what metadata expects (or regenerate the metadata)","If types are meant to be the same, fix scalar type mappings so the qualified type names match"],"exampleFix":"// before\nfilter: { count: { _gt: 10 } } // count returns BigInt, bool exp operand Int\n\n// after\nfilter: { count: { _gt: 10 } } // use BigInt-typed bool exp / aligned scalar","handlingStrategy":"validation","validationCode":"assert_eq!(count_agg.return_type.qualified_name(), bool_exp.operand_type.qualified_name(),\n    \"count aggregate / boolean expression type mismatch\");","typeGuard":"fn count_type_matches(ret: &QualifiedTypeName, operand: &QualifiedTypeName) -> bool {\n    ret == operand\n}","tryCatchPattern":"match resolve(expr) {\n    Err(ResolveError::CountAggregateTypeMismatch { count_type, .. }) => {\n        // select a bool exp typed for the count's scalar (e.g. BigInt) and retry\n    }\n    r => r,\n}","preventionTips":["Confirm the connector's count return scalar (Int vs BigInt vs custom) before writing count comparisons","Regenerate metadata when the count scalar type changes"],"tags":["rust","aggregate","count","type-mismatch","metadata"],"backgroundTag":null,"analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}