{"record":{"id":"65255be0787ccad6","repo":"dgraph-io/dgraph","slug":"fn-s-not-supported-in-preprocessfilter","errorCode":null,"errorMessage":"Fn %s not supported in preprocessFilter.","messagePattern":"Fn (.+?) not supported in preprocessFilter\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/task.go","lineNumber":2466,"sourceCode":"\t\t\tfor _, typeID := range commonTypeIDs {\n\t\t\t\t// TODO: if conversion is not possible we are not putting anything to map. In\n\t\t\t\t// applyFacetsTree we check if entry for a type is not present, we try to convert\n\t\t\t\t// it. This double conversion can be avoided.\n\t\t\t\tcv, err := types.Convert(ftree.function.val, typeID)\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tftree.function.typesToVal[typeID] = cv\n\t\t\t}\n\t\tcase standardFn:\n\t\t\targTokens, aerr := tok.GetTermTokens(tree.Func.Args)\n\t\t\tif aerr != nil { // query error ; stop processing.\n\t\t\t\treturn nil, aerr\n\t\t\t}\n\t\t\tsort.Strings(argTokens)\n\t\t\tftree.function.tokens = argTokens\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"Fn %s not supported in preprocessFilter.\", fname)\n\t\t}\n\t\treturn ftree, nil\n\t}\n\n\tfor _, c := range tree.Children {\n\t\tftreec, err := preprocessFilter(c)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tftree.children = append(ftree.children, ftreec)\n\t}\n\n\tnumChild := len(tree.Children)\n\tswitch ftree.op {\n\tcase \"not\":\n\t\tif numChild != 1 {\n\t\t\treturn nil, errors.Errorf(\"Expected 1 child for not but got %d.\", numChild)\n\t\t}","sourceCodeStart":2448,"sourceCodeEnd":2484,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/task.go#L2448-L2484","documentation":"During preprocessing of a filter tree into a facet filter tree, only certain function types (facet comparators) are allowed. If a function name parsed from the query is not in the supported set, preprocessFilter rejects it with this error.","triggerScenarios":"Using a function like uid_in, has, type(), or an unknown name inside an @facets filter, so the switch on fnType hits its default branch.","commonSituations":"Putting UID or scalar-predicate functions in facet filters; typos such as @facets(geq(x,1)); version drift where a function exists in newer Dgraph but not in the deployed one.","solutions":["Use only supported facet functions (eq, le, ge, lt, gt) inside @facets.","Move non-facet predicates (has, uid_in, type) out of @facets into the edge filter or func().","Verify function availability for your Dgraph version."],"exampleFix":"// before\nfriend @facets(uid_in(0x2))\n// after\nfriend filter uid_in(0x2) { @facets(eq(name, \"x\")) }","handlingStrategy":"validation","validationCode":"const preprocessableFns = new Set([\"eq\",\"le\",\"ge\",\"lt\",\"gt\"]);\nfunction checkFacetFns(query) {\n  for (const m of query.matchAll(/@facets\\((\\w+)/g)) {\n    if (!preprocessableFns.has(m[1])) throw new Error(`Fn not allowed in preprocessFilter: ${m[1]}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await txn.query(query);\n} catch (e) {\n  if (/not supported in preprocessFilter/.test(String(e))) {\n    // move the offending predicate out of @facets and retry\n  }\n  throw e;\n}","preventionTips":["Never place uid_in/has/type-style functions inside @facets.","Pin and test against your Dgraph version's supported facet functions.","Unit-test generated facet queries."],"tags":["dgraph","query","facets","preprocessing"],"backgroundTag":"unsupported-facet-function","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}