{"record":{"id":"6c9d533c7fdfb804","repo":"cayleygraph/cayley","slug":"errnovia","errorCode":"errNoVia","errorMessage":"expected predicate list","messagePattern":"expected predicate list","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/gizmo/errors.go","lineNumber":20,"sourceCode":"//\n// 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)","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/gizmo/errors.go#L2-L38","documentation":"errNoVia is returned when a traversal method that requires a via argument (inout, Both, FollowRecursive, LabelContext) receives arguments that toViaData cannot interpret as a predicate list. toViaData returns ok=false when no predicates/tags can be extracted, and the caller surfaces this error through the VM instead of panicking.","triggerScenarios":"Calling p.Both() or p.Inout() with no arguments, or with arguments that are not predicates/paths/strings (e.g. a bare object), so exportArgs/toViaData yields ok=false at traversals.go:112 (Both) or :197 (inout path).","commonSituations":"Handwritten gizmo scripts missing the predicate argument after refactors, or passing JS values (numbers, booleans) where predicate names are expected.","solutions":["Supply at least one predicate: p.Both(\"knows\") or a path p.Both(g.V(\"<alice\").out(\"knows\")).","Ensure arguments are strings, arrays of strings, or path objects — not plain objects or numbers.","If the traversal genuinely needs 'any', use a wildcard predicate as supported by the API rather than omitting via."],"exampleFix":"// before\np.Both().all()\n// after\np.Both(\"knows\").all()","handlingStrategy":"validation","validationCode":"if (!preds || (Array.isArray(preds) && preds.length === 0)) throw new Error('Both/inout requires at least one predicate');","typeGuard":"function hasVia(args) { return args.length > 0 && (typeof args[0] === 'string' || Array.isArray(args[0]) || args[0] instanceof mori.Path); }","tryCatchPattern":"try { p.Both(\"knows\").all(); } catch (e) { if (String(e).includes('expected predicate list')) { /* fix args */ } throw e; }","preventionTips":["Never call Both/Inout with zero arguments","Review refactored scripts for dropped predicate arguments","Use arrays of predicate strings for multi-predicate traversal"],"tags":["gizmo","query","missing-argument"],"backgroundTag":"missing-required-argument","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"}