{"record":{"id":"5e39d8553d58089e","repo":"dgraph-io/dgraph","slug":"unknown-query-type","errorCode":null,"errorMessage":"Unknown query type","messagePattern":"Unknown query type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"types/geofilter.go","lineNumber":207,"sourceCode":"\t\t\treturn []string{}, nil, errors.Errorf(\"Require a point for a within query.\")\n\t\t}\n\t\t// A near query is the same as the intersects query. We form a loop with the given point and\n\t\t// the radius and then see what all does it intersect with.\n\t\ttoks := parentCoverTokens(parents, cover)\n\t\treturn toks, &GeoQueryData{loops: loops, qtype: QueryTypeIntersects}, nil\n\n\tcase QueryTypeIntersects:\n\t\t// An intersects query is as the name suggests all the entities which intersect with the\n\t\t// given region. So we look at all the objects whose parents match our cover as well as\n\t\t// all the objects whose cover matches our parents.\n\t\tif len(loops) == 0 {\n\t\t\treturn nil, nil, errors.Errorf(\"Require a polygon for intersects query\")\n\t\t}\n\t\ttoks := parentCoverTokens(parents, cover)\n\t\treturn toks, &GeoQueryData{loops: loops, qtype: qt}, nil\n\n\tdefault:\n\t\treturn nil, nil, errors.Errorf(\"Unknown query type\")\n\t}\n}\n\n// MatchesFilter applies the query filter to a geo value\nfunc (q GeoQueryData) MatchesFilter(g geom.T) bool {\n\tswitch q.qtype {\n\tcase QueryTypeWithin:\n\t\treturn q.isWithin(g)\n\tcase QueryTypeContains:\n\t\treturn q.contains(g)\n\tcase QueryTypeIntersects:\n\t\treturn q.intersects(g)\n\tcase QueryTypeNear:\n\t\treturn q.intersects(g)\n\t}\n\treturn false\n}\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/types/geofilter.go#L189-L225","documentation":"A default-case error in queryTokensGeo meaning the supplied query type is not one of Within, Contains, Near, or Intersects. It indicates an unrecognized or unsupported geo query type value reached the token builder.","triggerScenarios":"Calling GetGeoTokens/queryTokens with a query type value outside the known QueryType constants, e.g. a typo, an uninitialized/zero-value query type, or a type added by a newer/older version mismatch.","commonSituations":"Constructing queries from user/JSON input where the 'type' string maps incorrectly to a QueryType constant; version skew between clients and this library.","solutions":["Use only the exported QueryType constants (QueryTypeWithin, QueryTypeContains, QueryTypeNear, QueryTypeIntersects)","Validate/whitelist the query type string before mapping it to a constant","Check for zero-value query structs where Type was never set"],"exampleFix":"// before\nqt := dgraph.QueryType(userInput) // arbitrary value\n// after\nvar qt dgraph.QueryType\nswitch userInput {\ncase \"within\": qt = dgraph.QueryTypeWithin\ncase \"intersects\": qt = dgraph.QueryTypeIntersects\ncase \"contains\": qt = dgraph.QueryTypeContains\ncase \"near\": qt = dgraph.QueryTypeNear\ndefault: return errors.New(\"unsupported geo query type\")\n}","handlingStrategy":"validation","validationCode":"switch qt {\ncase QueryTypeWithin, QueryTypeContains, QueryTypeNear, QueryTypeIntersects:\n    // ok\ndefault:\n    return errors.Errorf(\"unsupported geo query type: %v\", qt)\n}","typeGuard":"func isKnownQueryType(qt QueryType) bool {\n    switch qt {\n    case QueryTypeWithin, QueryTypeContains, QueryTypeNear, QueryTypeIntersects:\n        return true\n    }\n    return false\n}","tryCatchPattern":"toks, data, err := types.GetGeoTokens(qt, pt, loops, cover, parents)\nif err != nil && strings.Contains(err.Error(), \"Unknown query type\") {\n    // fix constant mapping; surface unsupported-type error\n}","preventionTips":["Never construct QueryType from raw integers or unchecked strings","Whitelist query-type strings at the API boundary","Keep client/server versions aligned on the QueryType enum"],"tags":["geo","query","invalid-input"],"backgroundTag":"unsupported-query-type","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}