{"record":{"id":"88129c9f4c7b941b","repo":"cayleygraph/cayley","slug":"errregexponiri","errorCode":"errRegexpOnIRI","errorMessage":"regexps are not allowed on IRIs","messagePattern":"regexps are not allowed on IRIs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/gizmo/errors.go","lineNumber":21,"sourceCode":"// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage gizmo\n\nimport \"fmt\"\n\nvar (\n\terrNoVia       = fmt.Errorf(\"expected predicate list\")\n\terrRegexpOnIRI = fmt.Errorf(\"regexps are not allowed on IRIs\")\n)\n\ntype errArgCount2 struct {\n\tExpected int\n\tGot      int\n}\n\nfunc (e errArgCount2) Error() string {\n\treturn fmt.Sprintf(\"expected %d argument, got %d\", e.Expected, e.Got)\n}\n\ntype errArgCount struct {\n\tGot int\n}\n\nfunc (e errArgCount) Error() string {\n\treturn fmt.Sprintf(\"unexpected arguments count: %d\", e.Got)\n}","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/gizmo/errors.go#L3-L39","documentation":"errRegexpOnIRI is thrown by cmpRegexp when a regular-expression filter is applied to a quad.IRI or quad.BNode value while refs are disallowed. The engine intentionally disallows regex matching against node identifiers to avoid expensive/unbounded scans, permitting regexps only on literal strings (unless allowRefs is enabled).","triggerScenarios":"Using a regexp-based filter (e.g. .filter(regex(...)) or comparison paths that reach environ.go:210/:214) where the current value is an IRI or blank node identifier rather than a string literal, and allowRefs is false.","commonSituations":"Scripts attempting regex on node IDs like g.V().out().filter(regex(\"person\")) where 'person' matches IRIs; users often expect regex to work on IRIs as in other graph query languages.","solutions":["Match on a literal property instead: save the relevant string field and regex against it.","Match the exact IRI with .Is(\"<...>\") rather than a regexp.","If IRI regex is truly needed, run in a context/configuration where allowRefs is enabled."],"exampleFix":"// before\nmori.g.V().filter(regex(\"person\"))\n// after\nmori.g.V().has(\"<name>\", regex(\"person\"))","handlingStrategy":"validation","validationCode":"if (isIRI(value) && usesRegex(filter)) { console.warn('regex on IRI is not allowed; use has() on a literal property'); }","typeGuard":"function isIRI(v) { return typeof v === 'string' && v.startsWith('<') && v.endsWith('>'); }","tryCatchPattern":"try { g.V().filter(regex('person')); } catch (e) { if (String(e).includes('regexps are not allowed on IRIs')) { /* switch to has() on a literal */ } throw e; }","preventionTips":["Apply regex only to literal properties via has()/save()","Use Is('<exact-iri>') for identifier matching","Avoid enabling allowRefs unless you accept the scan cost"],"tags":["gizmo","regex","iri","unsupported-operation"],"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"}