{"record":{"id":"18d83a9f2708ff29","repo":"cayleygraph/cayley","slug":"wildcard-unsupported-type-t","errorCode":null,"errorMessage":"wildcard: unsupported type: %T","messagePattern":"wildcard: unsupported type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/gizmo/environ.go","lineNumber":181,"sourceCode":"\t\tif len(args) != 1 {\n\t\t\treturn throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})\n\t\t}\n\t\tqv, err := toQuadValue(args[0])\n\t\tif err != nil {\n\t\t\treturn throwErr(vm, err)\n\t\t}\n\t\treturn vm.ToValue(valFilter{f: shape.Comparison{Op: op, Val: qv}})\n\t}\n}\n\nfunc cmpWildcard(vm *goja.Runtime, call goja.FunctionCall) goja.Value {\n\targs := exportArgs(call.Arguments)\n\tif len(args) != 1 {\n\t\treturn throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})\n\t}\n\tpattern, ok := args[0].(string)\n\tif !ok {\n\t\treturn throwErr(vm, fmt.Errorf(\"wildcard: unsupported type: %T\", args[0]))\n\t}\n\treturn vm.ToValue(valFilter{f: shape.Wildcard{Pattern: pattern}})\n}\n\nfunc cmpRegexp(vm *goja.Runtime, call goja.FunctionCall) goja.Value {\n\targs := exportArgs(call.Arguments)\n\tif len(args) != 1 && len(args) != 2 {\n\t\treturn throwErr(vm, errArgCount2{Expected: 1, Got: len(args)})\n\t}\n\tv, err := toQuadValue(args[0])\n\tif err != nil {\n\t\treturn throwErr(vm, err)\n\t}\n\tallowRefs := false\n\tif len(args) > 1 {\n\t\tb, ok := args[1].(bool)\n\t\tif !ok {\n\t\t\treturn throwErr(vm, fmt.Errorf(\"expected bool as second argument\"))","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/gizmo/environ.go#L163-L199","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ng.V().Has(\"name\", wildcard(42))\n// after\ng.V().Has(\"name\", wildcard(\"John*\"))","handlingStrategy":"type-guard","validationCode":"function safeWildcard(pattern) {\n  if (typeof pattern !== \"string\") throw new Error(\"wildcard pattern must be a string\");\n  return wildcard(pattern);\n}","typeGuard":"function isString(v) { return typeof v === \"string\"; }","tryCatchPattern":"try {\n  g.V().Has(\"name\", wildcard(pattern))\n} catch (e) {\n  if (String(e).includes(\"wildcard: unsupported type\")) {\n    g.V().Has(\"name\", wildcard(String(pattern)))\n  } else { throw e; }\n}","preventionTips":["Always pass string literals or String()-coerced values to wildcard","Initialize pattern variables with string defaults","Don't confuse wildcard patterns with RegExp objects"],"tags":["javascript","query","type-error","wildcard"],"backgroundTag":"invalid-argument-value","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}