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 have a scalar type representation mapping to the '{data_connector_name}' data connector's count aggregate type '{data_connector_count_return_type}' What it means
During metadata resolution, an aggregate expression uses the count (or single-row count) aggregate, but the return type of the aggregate cannot be mapped to the data connector's declared count aggregate type. The resolver found no scalar type representation mapping between the model's count return type and the connector's expected count type.
Source
Thrown at v3/crates/metadata-resolve/src/stages/models/error.rs:284
},
#[error(
"error in aggregate expression {aggregate_expression} used with the model {model_name}: {object_type_error}"
)]
ModelAggregateObjectTypeError {
model_name: Qualified<ModelName>,
aggregate_expression: Qualified<AggregateExpressionName>,
object_type_error: object_types::ObjectTypesError,
},
#[error(
"the aggregate expression '{aggregate_expression}' used with model '{model_name}' must use the Int type for its {count_type} aggregate as the data connector '{data_connector_name}' does not specify a count type in its schema"
)]
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,View on GitHub (pinned to 724551b9ae)
Solutions
- Check the connector's scalar_types for a type flagged as the aggregate count type and add a mapping for it
- Change the aggregate's return type to one the connector maps (e.g. Int/BigInt)
- Regenerate/refresh connector capabilities in metadata after connector upgrades
Example fix
// before
aggregates:
count:
output_type: scalar: MyCustomCounter
// after
aggregates:
count:
output_type: scalar: Int
Defensive patterns
Strategy: validation
Validate before calling
// before applying metadata, check the connector's scalar types include a representation for the count type let count_type = metadata.model_aggregates.count.output_type; assert!(connector.scalar_types.iter().any(|s| s.representations_contain(count_type)), "count type has no connector representation");
Prevention
- Keep aggregate return types to standard numerics (Int/BigInt)
- Run metadata validation/linting in CI before applying
When it happens
Trigger: Defining a selectAggregate with count on a model backed by a data connector whose scalar types don't include a representation for the count aggregate's return type (e.g. an exotic scalar type set).
Common situations: Custom/third-party data connectors that don't declare a count-compatible scalar type; changing a model's count return type; upgrading the connector SDK where count type mappings changed.
Related errors
- the aggregate expression {name} defines an aggregation funct
- the aggregate expression {name} defines an aggregation funct
- the return type used on the {count_type} aggregate ({return_
- the return type used on the {count_type} aggregate ({return_
- unknown data connector {data_connector:} referenced in objec
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/769fb7ab3697eee2.
Report an issue: GitHub.