{"record":{"id":"f4e50bb71b18033f","repo":"cayleygraph/cayley","slug":"unexpected-arguments-v-d","errorCode":null,"errorMessage":"unexpected arguments: %v (%d)","messagePattern":"unexpected arguments: (.+?) \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":173,"sourceCode":"\nfunc iterateObject(ctx context.Context, qs graph.QuadStore, f *field, p *path.Path) (out []map[string]interface{}, _ error) {\n\tif len(f.Labels) != 0 {\n\t\tp = p.LabelContext(f.Labels)\n\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 {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L155-L191","documentation":"In GraphQL-to-gizmo query translation, the special keys limit/skip must carry exactly one value; iterateObject returns this error when a limit or skip field has zero or multiple values. It is a query-shape validation enforced during execution of the parsed has-constraints.","triggerScenarios":"A GraphQL query where a @limit/@skip-style directive or field (quad.IRI(LimitKey)/SkipKey) resolves to h.Values with length != 1 — e.g. duplicating the limit key or supplying an array of values.","commonSituations":"Query builders that append limit values twice, or hand-crafted has-argument lists in tests/tools bypassing GraphQL schema validation.","solutions":["Ensure the query specifies limit (or skip) exactly once with a single integer value.","Deduplicate the generated Has constraints if you build them programmatically.","Validate the GraphQL document before execution so repeated limit/skip fields are rejected upstream."],"exampleFix":"// before (generated has constraints)\n{Via: LimitKey, Values: []interface{}{quad.Int(10), quad.Int(20)}}\n// after\n{Via: LimitKey, Values: []interface{}{quad.Int(10)}}","handlingStrategy":"validation","validationCode":"for (const h of has) { if ((h.Via === 'limit' || h.Via === 'skip') && h.Values.length !== 1) { throw new Error(h.Via + ' must have exactly one value'); } }","typeGuard":"function isValidLimitConstraint(h) { return h.Values.length === 1; }","tryCatchPattern":"out, err := iterateObject(ctx, qs, field, p)\nif err != nil && strings.Contains(err.Error(), \"unexpected arguments\") { /* dedupe limit/skip constraints */ }","preventionTips":["Specify limit/skip at most once per query","Deduplicate Has constraints when building them programmatically","Let GraphQL schema validation reject duplicate fields before execution"],"tags":["graphql","query","argument-count"],"backgroundTag":"invalid-query-parameter","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"}