{"record":{"id":"3b106b1ff7998096","repo":"cayleygraph/cayley","slug":"label-directive-should-have-0-or-1-argument","errorCode":null,"errorMessage":"label directive should have 0 or 1 argument","messagePattern":"label directive should have 0 or 1 argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":516,"sourceCode":"\tout.Labels = labels\n\tname := fld.Name.Value\n\tif fld.Alias != nil && fld.Alias.Value != \"\" {\n\t\tout.Alias = fld.Alias.Value\n\t} else {\n\t\tout.Alias = name\n\t}\n\tout.Via, out.Rev = stringToVia(name)\n\t// first check for \"label\" directive - it will affect all traversals\n\tfor _, d := range fld.Directives {\n\t\tif d.Name == nil {\n\t\t\tcontinue\n\t\t}\n\t\tswitch d.Name.Value {\n\t\tcase \"label\":\n\t\t\tif len(d.Arguments) == 0 {\n\t\t\t\tout.Labels = nil\n\t\t\t} else if len(d.Arguments) > 1 {\n\t\t\t\treturn out, fmt.Errorf(\"label directive should have 0 or 1 argument\")\n\t\t\t} else if a := d.Arguments[0]; a.Name == nil || a.Name.Value != \"v\" {\n\t\t\t\treturn out, fmt.Errorf(\"label directive should have 'v' argument\")\n\t\t\t} else {\n\t\t\t\tvals, err := convValue(a.Value)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn out, fmt.Errorf(\"error parsing label: %v\", err)\n\t\t\t\t}\n\t\t\t\tout.Labels = vals\n\t\t\t}\n\t\t}\n\t}\n\tfor _, d := range fld.Directives {\n\t\tif d.Name == nil {\n\t\t\tcontinue\n\t\t}\n\t\tswitch d.Name.Value {\n\t\tcase \"rev\", \"reverse\":\n\t\t\tif len(d.Arguments) == 0 {","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L498-L534","documentation":"The @label directive controls which labels (subgraphs) are traversed, and it accepts at most one argument. Supplying two or more arguments to @label is rejected with this error.","triggerScenarios":"A field directive `@label(v: \"a\", other: \"b\")` or any @label with len(d.Arguments) > 1 during convField, reached via Parse.","commonSituations":"Copy-pasted queries mixing dialects; guessing directive syntax; tools generating extra arguments on directives.","solutions":["Use at most one argument: `@label(v: ...)`","Pass multiple values via a list value in the single `v` argument if supported","Remove extra arguments from the directive"],"exampleFix":"// before\nq := \"query { node @label(v: \"a\", rev: true) { id } }\"\n// after\nq := \"query { node @label(v: \"a\") { id } }\"","handlingStrategy":"validation","validationCode":"function validateLabelDirective(field) {\n  const d = (field.directives || []).find(d => d.name.value === 'label');\n  if (d && d.arguments.length > 1) throw new Error('@label accepts at most one argument');\n}","typeGuard":"const hasValidLabelArgCount = (d) => !d || d.arguments.length <= 1;","tryCatchPattern":null,"preventionTips":["Remember @label signature: @label or @label(v: ...)","Lint directive usage against documented signatures","Copy directive syntax from official examples only"],"tags":["graphql","directive","argument-count"],"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"}