{"record":{"id":"389b1dfe8bc4e20e","repo":"cayleygraph/cayley","slug":"regexp-unsupported-type-t","errorCode":null,"errorMessage":"regexp: unsupported type: %T","messagePattern":"regexp: unsupported type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/gizmo/environ.go","lineNumber":217,"sourceCode":"\t\t\treturn throwErr(vm, fmt.Errorf(\"expected bool as second argument\"))\n\t\t}\n\t\tallowRefs = b\n\t}\n\tswitch vt := v.(type) {\n\tcase quad.String:\n\t\tif allowRefs {\n\t\t\tv = quad.IRI(string(vt))\n\t\t}\n\tcase quad.IRI:\n\t\tif !allowRefs {\n\t\t\treturn throwErr(vm, errRegexpOnIRI)\n\t\t}\n\tcase quad.BNode:\n\t\tif !allowRefs {\n\t\t\treturn throwErr(vm, errRegexpOnIRI)\n\t\t}\n\tdefault:\n\t\treturn throwErr(vm, fmt.Errorf(\"regexp: unsupported type: %T\", v))\n\t}\n\tvar (\n\t\ts    string\n\t\trefs bool\n\t)\n\tswitch v := v.(type) {\n\tcase quad.String:\n\t\ts = string(v)\n\tcase quad.IRI:\n\t\ts, refs = string(v), true\n\tcase quad.BNode:\n\t\ts, refs = string(v), true\n\tdefault:\n\t\treturn throwErr(vm, fmt.Errorf(\"regexp from non-string value: %T\", v))\n\t}\n\tre, err := regexp.Compile(string(s))\n\tif err != nil {\n\t\treturn throwErr(vm, err)","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/gizmo/environ.go#L199-L235","documentation":"In cmpRegexp, the first argument is converted to a quad.Value and then type-switched; only quad.String, quad.IRI, and quad.BNode are valid operands for a regexp value filter. If the converted quad value is any other type (e.g. quad.LangString or quad.Raw/TypedString), this error is thrown reporting the unsupported Go type. It exists because regexp filters can only be evaluated over string-like values.","triggerScenarios":"Calling regexp(...) in a Gizmo/JS query whose first argument converts to an unsupported quad.Value type — e.g. passing a raw/typed/lang-string value via raw(\"...\") or a typed literal, instead of str(), iri(), or bnode().","commonSituations":"Matching on values created with raw() or language-tagged literals rather than plain strings; schema changes that switched node values from strings to typed literals; passing objects that toQuadValue maps to non-string quad types.","solutions":["Pass a plain string created via str(\"...\") so the value is quad.String","If matching IRI/BNode references, pass iri(...)/bnode(...) and set the second argument to true","Convert or cast the value to a string before applying the regexp filter","Match on a different predicate whose values are plain strings"],"exampleFix":"// before\ng.V().Has(\"name\", regexp(raw(\"^Al\")))\n// after\ng.V().Has(\"name\", regexp(str(\"^Al\")))","handlingStrategy":"type-guard","validationCode":"function safeRegexpValue(v) {\n  // only str(), iri(), bnode() quad values are supported\n  return regexp(str(String(v)));\n}","typeGuard":null,"tryCatchPattern":"try {\n  g.V().Has(\"name\", regexp(v))\n} catch (e) {\n  if (String(e).includes(\"regexp: unsupported type\")) {\n    g.V().Has(\"name\", regexp(str(String(v))))\n  } else { throw e; }\n}","preventionTips":["Build regexp operands with str(), iri(), or bnode() only","Avoid raw() and typed/languaged literals as regexp inputs","Remember IRIs and BNodes require the second allowRefs=true argument"],"tags":["query","regexp","type-error","quad-values"],"backgroundTag":"unsupported-operation","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"}