cayleygraph/cayley · error
wildcard: unsupported type: %T
Error message
wildcard: unsupported type: %T
What it means
In the Gizmo JS query environment, the wildcard comparison helper (cmpWildcard) requires its single argument to be a JavaScript string that becomes the wildcard match pattern. If the argument is any other JS type (number, object, undefined, etc.), the query engine throws this error naming the offending Go/JS type. The wildcard filter (shape.Wildcard) can only be built from a string pattern.
Source
Thrown at query/gizmo/environ.go:181
if len(args) != 1 {
return throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})
}
qv, err := toQuadValue(args[0])
if err != nil {
return throwErr(vm, err)
}
return vm.ToValue(valFilter{f: shape.Comparison{Op: op, Val: qv}})
}
}
func cmpWildcard(vm *goja.Runtime, call goja.FunctionCall) goja.Value {
args := exportArgs(call.Arguments)
if len(args) != 1 {
return throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})
}
pattern, ok := args[0].(string)
if !ok {
return throwErr(vm, fmt.Errorf("wildcard: unsupported type: %T", args[0]))
}
return vm.ToValue(valFilter{f: shape.Wildcard{Pattern: pattern}})
}
func cmpRegexp(vm *goja.Runtime, call goja.FunctionCall) goja.Value {
args := exportArgs(call.Arguments)
if len(args) != 1 && len(args) != 2 {
return throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})
}
v, err := toQuadValue(args[0])
if err != nil {
return throwErr(vm, err)
}
allowRefs := false
if len(args) > 1 {
b, ok := args[1].(bool)
if !ok {
return throwErr(vm, fmt.Errorf("expected bool as second argument"))View on GitHub (pinned to 81dcd7d73e)
Solutions
- Pass a plain string as the wildcard pattern, e.g. wildcard("prefix:*")
- Coerce values with String(pattern) or template literals before calling wildcard
- Check for undefined/null caused by typos or missing arguments
- Use regexp(...) if you genuinely need pattern matching over non-string quad values
Example fix
// before
g.V().Has("name", wildcard(42))
// after
g.V().Has("name", wildcard("John*")) Defensive patterns
Strategy: type-guard
Validate before calling
function safeWildcard(pattern) {
if (typeof pattern !== "string") throw new Error("wildcard pattern must be a string");
return wildcard(pattern);
} Type guard
function isString(v) { return typeof v === "string"; } Try / catch
try {
g.V().Has("name", wildcard(pattern))
} catch (e) {
if (String(e).includes("wildcard: unsupported type")) {
g.V().Has("name", wildcard(String(pattern)))
} else { throw e; }
} Prevention
- Always pass string literals or String()-coerced values to wildcard
- Initialize pattern variables with string defaults
- Don't confuse wildcard patterns with RegExp objects
When it happens
Trigger: Calling the wildcard(...) function from a Gizmo/JS query with a non-string argument, e.g. wildcard(42), wildcard(null), wildcard(undefined), or forgetting to pass any argument so args[0] is undefined. Also occurs when a variable holding the pattern is not a string.
Common situations: Query scripts built programmatically where the pattern variable is a number or null; passing a JS RegExp object instead of a string pattern; typos in variable names yielding undefined.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- expected bool as second argument
- regexp: unsupported type: %T
- must specify a tag name when saving a path
- invalid argument type in filter()
- must execute a Step
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/18d83a9f2708ff29.
Report an issue: GitHub.