{"record":{"id":"ea2e4785220c21bd","repo":"cayleygraph/cayley","slug":"unexpected-value-type-for-v-t","errorCode":null,"errorMessage":"unexpected value type for %v: %T","messagePattern":"unexpected value type for (.+?): %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":177,"sourceCode":"\t} else {\n\t\tp = p.LabelContext()\n\t}\n\tvar (\n\t\tlimit = -1\n\t\tskip  = 0\n\t)\n\n\tfor _, h := range f.Has {\n\t\tswitch h.Via {\n\t\tcase quad.IRI(ValueKey): // special key - \"id\"\n\t\t\tp = p.Is(h.Values...)\n\t\tcase quad.IRI(LimitKey), quad.IRI(SkipKey): // limit and skip\n\t\t\tif len(h.Values) != 1 {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected arguments: %v (%d)\", h.Values, len(h.Values))\n\t\t\t}\n\t\t\tn, ok := h.Values[0].(quad.Int)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected value type for %v: %T\", string(h.Via), h.Values[0])\n\t\t\t}\n\t\t\tif h.Via == quad.IRI(LimitKey) {\n\t\t\t\tlimit = int(n)\n\t\t\t} else {\n\t\t\t\tskip = int(n)\n\t\t\t\tif skip < 0 {\n\t\t\t\t\tskip = 0\n\t\t\t\t}\n\t\t\t}\n\t\tdefault: // everything else - Has constraint\n\t\t\tif len(h.Labels) != 0 {\n\t\t\t\tp = p.LabelContext(h.Labels)\n\t\t\t}\n\t\t\tif h.Rev {\n\t\t\t\tp = p.HasReverse(h.Via, h.Values...)\n\t\t\t} else {\n\t\t\t\tp = p.Has(h.Via, h.Values...)\n\t\t\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L159-L195","documentation":"When translating limit/skip constraints, iterateObject requires the single value to be a quad.Int; any other value type (string, float, bool) returns this error naming the key and the offending Go type. This enforces that pagination parameters are integers.","triggerScenarios":"A limit/skip value that is not a quad.Int — e.g. quad.String(\"10\"), a float, or a boolean — passed in the Has constraint at query/graphql/graphql.go:177.","commonSituations":"Queries with quoted numbers (limit: \"10\"), JSON parsers producing float64 for integers that were never converted to quad.Int, or hand-built constraint lists in Go code.","solutions":["Convert the value to quad.Int before building the Has constraint (quad.Int(n)).","Ensure the GraphQL layer coerces integer-typed fields and rejects strings at parse time.","If you receive this from user input, validate that limit/skip are integers (no quotes) in the request."],"exampleFix":"// before\nValues: []interface{}{quad.String(\"10\")}\n// after\nValues: []interface{}{quad.Int(10)}","handlingStrategy":"validation","validationCode":"if (typeof limit !== 'number' || !Number.isInteger(limit)) throw new Error('limit/skip must be integers');","typeGuard":"func isQuadInt(v interface{}) bool { _, ok := v.(quad.Int); return ok }","tryCatchPattern":"out, err := iterateObject(ctx, qs, field, p)\nif err != nil && strings.Contains(err.Error(), \"unexpected value type\") { /* coerce to quad.Int */ }","preventionTips":["Build limit/skip values as quad.Int on the Go side","Reject quoted numbers in GraphQL integer fields at parse time","Convert float64 inputs to int64 before constructing constraints"],"tags":["graphql","query","type-mismatch","pagination"],"backgroundTag":"type-mismatch","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}