{"record":{"id":"fa57f88558d1b5da","repo":"hasura/graphql-engine","slug":"the-aggregate-expression-name-specifies-an-aggre-fa57f8","errorCode":null,"errorMessage":"the aggregate expression {name} specifies an aggregation function '{function_name}' that uses an unknown type for its return type: {type_name}","messagePattern":"the aggregate expression (.+?) specifies an aggregation function '(.+?)' that uses an unknown type for its return type: (.+?)","errorType":"validation","errorClass":"AggregateExpressionError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/aggregates/types.rs","lineNumber":204,"sourceCode":"    },\n\n    #[error(\n        \"the aggregate expression {name} specifies an operand scalar type that cannot be found: {type_name}\"\n    )]\n    AggregateOperandScalarTypeNotFound {\n        name: Qualified<AggregateExpressionName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n\n    #[error(\n        \"the aggregate expression {name} has duplicate definitions of the aggregation function '{function_name}'\"\n    )]\n    AggregateOperandFunctionDuplicated {\n        name: Qualified<AggregateExpressionName>,\n        function_name: AggregationFunctionName,\n    },\n\n    #[error(\n        \"the aggregate expression {name} specifies an aggregation function '{function_name}' that uses an unknown type for its return type: {type_name}\"\n    )]\n    AggregateOperandFunctionUnknownReturnType {\n        name: Qualified<AggregateExpressionName>,\n        function_name: AggregationFunctionName,\n        type_name: CustomTypeName,\n    },\n\n    #[error(\n        \"the aggregate expression {name} defines an aggregation function mapping to an unknown data connector: {data_connector_name}\"\n    )]\n    AggregateOperandDataConnectorMissing {\n        name: Qualified<AggregateExpressionName>,\n        data_connector_name: Qualified<DataConnectorName>,\n    },\n\n    #[error(\n        \"the aggregate expression {name} defines an aggregation function mapping to a data connector that does not support aggregates: {data_connector_name}\"","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/aggregates/types.rs#L186-L222","documentation":"An aggregate expression declares an aggregation function whose `return_type` references a custom type that the metadata resolver does not know about. All return types must resolve to either built-in scalar types or custom types defined in the same metadata.","triggerScenarios":"An aggregate expression function entry whose return type references a `CustomTypeName` that has no corresponding ObjectType/scalar definition in the resolved metadata (misspelled name, wrong subgraph/namespace, or type file not included).","commonSituations":"Renaming or deleting a custom scalar type without updating aggregate expressions; referencing a type from a different namespace; a missing `types` metadata file in the build; case/typo mistakes in type names.","solutions":["Check the exact type name in the error and verify a matching type exists in your metadata (correct spelling, namespace/subgraph)","If the type lives elsewhere, qualify the return type with the right subgraph/namespace or move the type into scope","If the type was removed intentionally, switch the function's return type to a built-in scalar (e.g. Float, Int)","Rebuild metadata with `ddn build`"],"exampleFix":"# before\nfunctions:\n  - name: avg\n    return_type: my_namespace.Revenue # undefined type\n# after\nfunctions:\n  - name: avg\n    return_type: Float","handlingStrategy":"validation","validationCode":"# Collect known custom type names from all kinds: ObjectType/scalar metadata, then:\nknown = {t['name'] for t in all_types}\nassert fn_return_type.split('.')[-1] in known or fn_return_type in BUILTIN_SCALARS, f'unknown return type {fn_return_type}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single source of truth for type names; use `ddn build` to regenerate references","When renaming/removing a type, grep metadata for all usages including aggregate expressions"],"tags":["opendd","metadata","aggregates","return-type","unknown-type"],"backgroundTag":"metadata-schema-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}