{"record":{"id":"e2a4c81dce081a7e","repo":"dgraph-io/dgraph","slug":"invalid-function-name-s","errorCode":null,"errorMessage":"Invalid function name: %s","messagePattern":"Invalid function name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/query.go","lineNumber":465,"sourceCode":"\n\tfor _, mc := range src.Child {\n\t\tchild := &mathTree{}\n\t\tif err := mathCopy(child, mc); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdst.Child = append(dst.Child, child)\n\t}\n\treturn nil\n}\n\nfunc filterCopy(sg *SubGraph, ft *dql.FilterTree) error {\n\t// Either we'll have an operation specified, or the function specified.\n\tif len(ft.Op) > 0 {\n\t\tsg.FilterOp = ft.Op\n\t} else {\n\t\tsg.Attr = ft.Func.Attr\n\t\tif !isValidFuncName(ft.Func.Name) {\n\t\t\treturn errors.Errorf(\"Invalid function name: %s\", ft.Func.Name)\n\t\t}\n\n\t\tif isUidFnWithoutVar(ft.Func) {\n\t\t\tsg.SrcFunc = &Function{Name: ft.Func.Name}\n\t\t\tif err := sg.populate(ft.Func.UID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tif ft.Func.Attr == \"uid\" {\n\t\t\t\treturn errors.Errorf(`Argument cannot be \"uid\"`)\n\t\t\t}\n\t\t\tsg.createSrcFunction(ft.Func)\n\t\t\tsg.Params.NeedsVar = append(sg.Params.NeedsVar, ft.Func.NeedsVar...)\n\t\t}\n\t}\n\tfor _, ftc := range ft.Child {\n\t\tchild := &SubGraph{}\n\t\tif err := filterCopy(child, ftc); err != nil {","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/query.go#L447-L483","documentation":"filterCopy translates a DQL filter tree into a SubGraph. When a filter uses a function, the function name is checked against isValidFuncName; an unrecognized name yields \"Invalid function name: %s\". This is DQL query validation failing at graph-construction time (newGraph/treeCopy/filterCopy recursion).","triggerScenarios":"A filter with a misspelled or non-existent function, e.g. `@filter(alike(name, \"x\"))` or `@filter(equals(name, \"x\"))` instead of valid names like eq/le/ge/lt/gt/allofterms/anyofterms/uid/has.","commonSituations":"Typos in filter functions (eq vs equals), functions valid only in root (not allowed in filter) contexts, or copied SQL-style function names.","solutions":["Correct the function name to a valid DQL filter function (eq, lt, le, gt, ge, has, uid, allofterms, anyofterms, allofterms, match, type, etc.)","Check whether the function is root-only (e.g. some funcs allowed at func: but not in @filter)","Upgrade Dgraph if the function exists only in a newer version"],"exampleFix":"// before\n{ q(func: type(Person)) @filter(equals(name, \"Alice\")) { uid } }\n// after\n{ q(func: type(Person)) @filter(eq(name, \"Alice\")) { uid } }","handlingStrategy":"validation","validationCode":"// Go client-side: validate filter functions before sending query\nvar validFilterFuncs = map[string]bool{\"eq\":true,\"lt\":true,\"le\":true,\"gt\":true,\"ge\":true,\"has\":true,\"uid\":true,\"allofterms\":true,\"anyofterms\":true,\"alloftext\":true,\"anyoftext\":true,\"match\":true,\"type\":true}\nfor name := range parsedFilterFuncs {\n    if !validFilterFuncs[name] {\n        return fmt.Errorf(\"invalid filter function: %s\", name)\n    }\n}","typeGuard":"func isValidFilterFunc(name string) bool {\n    valid := []string{\"eq\",\"lt\",\"le\",\"gt\",\"ge\",\"has\",\"uid\",\"allofterms\",\"anyofterms\",\"alloftext\",\"anyoftext\",\"match\",\"type\"}\n    return slices.Contains(valid, name)\n}","tryCatchPattern":"_, err := txn.Query(ctx, dql)\nvar te *api.TxnFinishedError // generic path\nif err != nil && strings.Contains(err.Error(), \"Invalid function name\") {\n    fn := extractFuncName(err.Error())\n    return fmt.Errorf(\"check DQL docs for function %q; did you mean eq/allofterms?\", fn)\n}","preventionTips":["Validate DQL with a schema-aware query builder before sending","Keep a canonical list of valid filter functions for your Dgraph version","Watch for root-only functions used inside @filter"],"tags":["dgraph","dql","filter","invalid-function"],"backgroundTag":"invalid-dql-function-name","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}