{"record":{"id":"ce7200d236064a67","repo":"dgraph-io/dgraph","slug":"unhandled-aggregator-function-q","errorCode":null,"errorMessage":"Unhandled aggregator function %q","messagePattern":"Unhandled aggregator function %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/aggregator.go","lineNumber":788,"sourceCode":"\tif ag.result.Value == nil {\n\t\tag.result = v\n\t\treturn nil\n\t}\n\n\tleft := ag.result\n\tif err := ag.matchType(&left, &v); err != nil {\n\t\treturn err\n\t}\n\n\tif function, ok := binaryFunctions[ag.name]; ok {\n\t\tres.Tid = left.Tid\n\t\terr := function(&left, &v, &res)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tag.result = res\n\t} else {\n\t\treturn errors.Errorf(\"Unhandled aggregator function %q\", ag.name)\n\t}\n\n\treturn nil\n}\n\nfunc (ag *aggregator) Apply(val types.Val) error {\n\tif ag.result.Value == nil {\n\t\tif val.Tid == types.VFloatID {\n\t\t\t// Copy array if it's VFloat, otherwise we overwrite value.\n\t\t\tva := val.Value.([]float32)\n\t\t\tres := make([]float32, len(va))\n\t\t\tcopy(res, va)\n\t\t\tag.result = types.Val{Tid: types.VFloatID, Value: res}\n\t\t} else {\n\t\t\tag.result = val\n\t\t}\n\t\tag.count++\n\t\treturn nil","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/aggregator.go#L770-L806","documentation":"aggregator.ApplyVal looks up the aggregator's name in the registered function maps (unaryFunctions/binaryFunctions and the aggregation registry). If ag.name does not match any registered aggregator, it returns this error quoting the unknown function name. This means the query requested an aggregation/math function that this Dgraph build does not know.","triggerScenarios":"A query references an aggregator or math function name not present in the registry (typo like 'sums', a function added in a newer Dgraph version, or an unsupported name reaching ApplyVal via processBinary/processUnary or an anonymous caller).","commonSituations":"Typos in math function names; using a function from a newer Dgraph release on an older server; custom/renamed aggregators; query built programmatically with a wrong function string.","solutions":["Check the function name spelling in the query against Dgraph's supported math/aggregation functions","Upgrade the Dgraph server if the function exists only in newer versions","Verify the query variable/alias holding the function name is correct when queries are generated dynamically","Consult the server version's documentation for the available aggregator list"],"exampleFix":"// before: unknown function\n\"math summ(x)\"\n// after: registered function\n\"math sum(x)\"","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['sum','min','max','count','avg','ln','exp','sqrt','floor','ceil','since'];\nfunction validateFn(name) {\n  if (!SUPPORTED.includes(name)) throw new Error('Unsupported function: ' + name);\n}","typeGuard":null,"tryCatchPattern":"try {\n  r = await txn.query(q);\n} catch (e) {\n  if (String(e).includes('Unhandled aggregator function')) {\n    console.error('Unknown function:', e.message.match(/\"([^\"]+)\"/)[1]);\n  }\n  throw e;\n}","preventionTips":["Cross-check function names against the server version's docs","Pin client and server versions to avoid feature drift","Validate dynamically generated queries against a whitelist","Add integration tests for every function used"],"tags":["dgraph","query","aggregator","unsupported-function"],"backgroundTag":"unsupported-function-name","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}