hasura/graphql-engine · error · ModelAggregateExpressionError
the aggregate expression '{aggregate_expression}' is used wi
Error message
the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not match the count aggregate scalar type defined by the data connector '{data_connector_name}': {expected_count_return_type} What it means
The return type declared for a count aggregate does not match the scalar type the data connector declares for its count aggregate. The resolver compared the aggregate's QualifiedTypeName against the connector's DataConnectorScalarType and found a mismatch.
Source
Thrown at v3/crates/metadata-resolve/src/stages/models/error.rs:295
)]
CountReturnTypeMustBeInt {
aggregate_expression: Qualified<AggregateExpressionName>,
model_name: Qualified<ModelName>,
count_type: aggregates::CountAggregateType,
data_connector_name: Qualified<DataConnectorName>,
},
#[error(
"the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not have a scalar type representation mapping to the '{data_connector_name}' data connector's count aggregate type '{data_connector_count_return_type}'"
)]
CountReturnTypeMappingMissing {
model_name: Qualified<ModelName>,
aggregate_expression: Qualified<AggregateExpressionName>,
count_type: aggregates::CountAggregateType,
count_return_type: QualifiedTypeName,
data_connector_name: Qualified<DataConnectorName>,
data_connector_count_return_type: DataConnectorScalarType,
},
#[error(
"the aggregate expression '{aggregate_expression}' is used with the model '{model_name}' but the {count_type} aggregate's return type ({count_return_type}) does not match the count aggregate scalar type defined by the data connector '{data_connector_name}': {expected_count_return_type}"
)]
CountReturnTypeMappingMismatch {
model_name: Qualified<ModelName>,
aggregate_expression: Qualified<AggregateExpressionName>,
count_type: aggregates::CountAggregateType,
count_return_type: QualifiedTypeName,
data_connector_name: Qualified<DataConnectorName>,
expected_count_return_type: QualifiedTypeName,
},
#[error("{0}")]
AggregateExpressionError(#[from] aggregates::AggregateExpressionError),
}
View on GitHub (pinned to 724551b9ae)
Solutions
- Align the aggregate's return type with the connector's declared count type
- Update the connector capabilities block to declare the count type you actually use
- Re-sync metadata after upgrading the connector
Example fix
// before count: output_type: scalar: Float // after count: output_type: scalar: BigInt # matches connector's count type
Defensive patterns
Strategy: validation
Validate before calling
// assert the aggregate's declared return type equals the connector's count type assert_eq!(model.count_output_type, connector.count_aggregate_type);
Prevention
- Pin connector versions and re-validate count types on upgrade
- Generate aggregate metadata from connector capabilities rather than by hand
When it happens
Trigger: Declaring count's output type as e.g. Float while the connector declares its count aggregate type as BigInt; mixing Int/BigInt between metadata and connector capabilities.
Common situations: Hand-written metadata where count returns a different numeric type than the connector's; connector version upgrades that changed the count scalar type.
Related errors
- the return type used on the {count_type} aggregate ({return_
- type mismatch between the '{count_type}' aggregate (return t
- the type of the comparable field '{field_name}' ({field_type
- the return type used on the {count_type} aggregate ({return_
- The field {field_name:} has type {field_type:} but the field
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/f60e84d4cb94d0c3.
Report an issue: GitHub.