{"record":{"id":"fd012f64a147f21a","repo":"cayleygraph/cayley","slug":"error-parsing-label-v","errorCode":null,"errorMessage":"error parsing label: %v","messagePattern":"error parsing label: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/graphql/graphql.go","lineNumber":522,"sourceCode":"\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 {\n\t\t\t\tout.Rev = out.Rev != true\n\t\t\t} else {\n\t\t\t\tout.Has, err = argsToHas(out.Has, d.Arguments, true, out.Labels)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/graphql/graphql.go#L504-L540","documentation":"The value supplied to @label's `v` argument could not be converted by convValue into quad values (labels must be resolvable to IRIs/strings). The underlying conversion error is wrapped with this prefix.","triggerScenarios":"A @label directive whose argument value is an unsupported literal kind (e.g. an object value, a variable that fails conversion, or another non-convertible node), causing convValue to return an error inside convField.","commonSituations":"Passing GraphQL variables not provided in the variables map; using object/list literals where a string/IRI is expected; schema tooling emitting enum or object values for the label.","solutions":["Pass a plain string or valid IRI value: `@label(v: \"myLabel\")`","If using a variable ($v), ensure it is supplied in the query variables and converts to a string","Inspect the wrapped inner error (%v) for the exact conversion failure"],"exampleFix":"// before\nq := \"query { node @label(v: $missing) { id } }\" // variable not provided\n// after\nq := \"query { node @label(v: \"myLabel\") { id } }\"","handlingStrategy":"try-catch","validationCode":"// Ensure label values are plain strings or valid IRIs before sending\nfunction isConvertibleLabel(v) {\n  return typeof v.value === 'string' || (v.kind === 'Variable' && typeof variables[v.name.value] === 'string');\n}","typeGuard":"const isStringOrIRI = (x) => typeof x === 'string' || /^https?:\\/\\//.test(x ?? '');","tryCatchPattern":"result, err := engine.Parse(ctx, q)\nif err != nil {\n  if strings.HasPrefix(err.Error(), \"error parsing label:\") {\n    return fmt.Errorf(\"check @label(v: ...) value is a string/IRI and variables are provided: %w\", err)\n  }\n  return err\n}","preventionTips":["Pass label values as plain strings","Supply all GraphQL variables used in directives","Avoid object/list literals in @label arguments"],"tags":["graphql","directive","value-conversion"],"backgroundTag":"invalid-argument-value","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"}