{"record":{"id":"ad6bf691d5185025","repo":"hasura/graphql-engine","slug":"a-field-field-name-with-an-aggregatablefield-a","errorCode":null,"errorMessage":"A field ({field_name}) with an AggregatableField annotation was found on a scalar-typed ({aggregate_operand_type}) operand's selection set","messagePattern":"A field \\((.+?)\\) with an AggregatableField annotation was found on a scalar-typed \\((.+?)\\) operand's selection set","errorType":"exception","errorClass":"InternalDeveloperError","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/ir/src/error.rs","lineNumber":231,"sourceCode":"\n    #[error(\n        \"Argument mapping not found for the argument {argument_name:} while executing the relationship {relationship_name:}\"\n    )]\n    ArgumentMappingNotFoundForRelationship {\n        relationship_name: RelationshipName,\n        argument_name: ArgumentName,\n    },\n\n    #[error(\n        \"The aggregation function {aggregation_function} operating over the {aggregate_operand_type} type is missing a data connector mapping for {data_connector_name}\"\n    )]\n    DataConnectorAggregationFunctionNotFound {\n        aggregate_operand_type: QualifiedTypeName,\n        aggregation_function: AggregationFunctionName,\n        data_connector_name: Qualified<DataConnectorName>,\n    },\n\n    #[error(\n        \"A field ({field_name}) with an AggregatableField annotation was found on a scalar-typed ({aggregate_operand_type}) operand's selection set\"\n    )]\n    AggregatableFieldFoundOnScalarTypedOperand {\n        field_name: FieldName,\n        aggregate_operand_type: QualifiedTypeName,\n    },\n\n    #[error(\n        \"The aggregation function {aggregation_function} was used on the model object type and not on a model field. Aggregation functions operate on columns, not rows\"\n    )]\n    ColumnAggregationFunctionUsedOnModelObjectType {\n        aggregate_operand_type: QualifiedTypeName,\n        aggregation_function: AggregationFunctionName,\n    },\n\n    #[error(\"{0}\")]\n    PlanInternalDeveloperError(plan::InternalDeveloperError),\n}","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/ir/src/error.rs#L213-L249","documentation":"A field carrying an AggregatableField annotation appeared inside the selection set of an aggregation operand that is scalar-typed. Scalar operands have no subfields, so an aggregatable field there is a contradiction detected during IR validation.","triggerScenarios":"Selecting aggregatable subfields under a scalar operand in an _aggregate query; malformed aggregate selections generated by hand or by buggy query builders; metadata marking a scalar operand as having aggregatable fields.","commonSituations":"Hand-written aggregate queries with wrong nesting; codegen producing deeply nested aggregate fragments incorrectly.","solutions":["Restructure the aggregate selection so aggregatable fields only appear under object/array-typed operands","Use the standard client-generated aggregate query shape","Validate the aggregate query against the schema before execution"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Only nest aggregatable fields under object-typed operands\nif (isScalarType(operandType) && selectionHasFields(sel)) throw new Error('bad aggregate shape');","typeGuard":"const isValidAggregateSelection = (operandType, sel) =>\n  !isScalarType(operandType) || sel.selectionSet === undefined;","tryCatchPattern":"// Catch and restructure the aggregate selection to the documented shape","preventionTips":["Use generated clients for aggregate queries","Review aggregate query nesting against docs"],"tags":["graphql","aggregation","selection-set"],"backgroundTag":"invalid-aggregate-selection","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}