{"record":{"id":"180e131e5c1a6660","repo":"cayleygraph/cayley","slug":"unsupported-type-t","errorCode":null,"errorMessage":"unsupported type: %T","messagePattern":"unsupported type: %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/gizmo/environ.go","lineNumber":394,"sourceCode":"\t\t} else if v, ok := via[0].([]interface{}); ok {\n\t\t\treturn toVia(v)\n\t\t} else if v, ok := via[0].([]string); ok {\n\t\t\tarr := make([]interface{}, 0, len(v))\n\t\t\tfor _, s := range v {\n\t\t\t\tarr = append(arr, s)\n\t\t\t}\n\t\t\treturn toVia(arr)\n\t\t}\n\t}\n\tfor i := range via {\n\t\tif _, ok := via[i].(*path.Path); ok {\n\t\t\t// bypass\n\t\t} else if vp, ok := via[i].(*pathObject); ok {\n\t\t\tvia[i] = vp.path\n\t\t} else if qv, err := toQuadValue(via[i]); err == nil {\n\t\t\tvia[i] = qv\n\t\t} else {\n\t\t\tpanic(fmt.Errorf(\"unsupported type: %T\", via[i]))\n\t\t}\n\t}\n\treturn via\n}\n\nfunc toViaData(objs []interface{}) (predicates []interface{}, tags []string, ok bool) {\n\tif len(objs) != 0 {\n\t\tpredicates = toVia([]interface{}{objs[0]})\n\t}\n\tif len(objs) > 1 {\n\t\ttags = toStrings(objs[1:])\n\t}\n\tok = true\n\treturn\n}\n\nfunc toViaDepthData(objs []interface{}) (predicates []interface{}, maxDepth int, tags []string, ok bool) {\n\tif len(objs) != 0 {","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/gizmo/environ.go#L376-L412","documentation":"toVia normalizes a via argument list so each element becomes a path, *pathObject, or a quad value; when an element cannot be converted by toQuadValue and is not a path-like object, it panics with \"unsupported type\". This is gizmo's guard that traversal 'via' arguments are predicates, paths, or plain query values.","triggerScenarios":"Passing a via element of an unsupported Go/JS type — e.g. a function, undefined/null, nested pathObject inside a deep structure, or a goja object with no quad representation — into pathObject.Via-derived code paths (Both/FollowRecursive via toViaData/toViaDepthData).","commonSituations":"Gizmo scripts passing JS objects or functions as predicates (e.g. .both({a:1})), or API users embedding values like maps that have no quad equivalent.","solutions":["Pass a string predicate, a *pathObject (result of g.V(...)/p.out(...)), or a simple scalar value for via.","Check the %T in the panic to see the offending type and convert it (e.g. .toString() in JS or quad value on the Go side).","For composite conditions build a proper path expression instead of raw objects."],"exampleFix":"// before\np.Both({pred: \"knows\"})\n// after\np.Both(\"knows\")","handlingStrategy":"type-guard","validationCode":"const isValidVia = v => typeof v === 'string' || v instanceof mori.Path || ['string','number','boolean'].includes(typeof v);\nif (!viaArgs.every(isValidVia)) throw new Error('unsupported via element');","typeGuard":"function isPathLike(v) { return v instanceof mori.Path || typeof v === 'string'; }","tryCatchPattern":null,"preventionTips":["Pass only strings, paths, or scalars as via arguments","Never pass JS objects, functions, or undefined into via lists","Check the %T in the panic message when debugging embedded Go callers"],"tags":["gizmo","query","unsupported-type","panic"],"backgroundTag":"incompatible-source-type","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"}