{"record":{"id":"c2878656649a7246","repo":"grafana/k6","slug":"method-q-not-found-in-file-descriptors","errorCode":null,"errorMessage":"method %q not found in file descriptors","messagePattern":"method %q not found in file descriptors","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/client.go","lineNumber":366,"sourceCode":") (grpcext.InvokeRequest, error) {\n\tgrpcReq := grpcext.InvokeRequest{}\n\n\tstate := c.vu.State()\n\tif state == nil {\n\t\treturn grpcReq, common.NewInitContextError(\"invoking RPC methods in the init context is not supported\")\n\t}\n\tif c.conn == nil {\n\t\treturn grpcReq, errors.New(\"no gRPC connection, you must call connect first\")\n\t}\n\tif method == \"\" {\n\t\treturn grpcReq, errors.New(\"method to invoke cannot be empty\")\n\t}\n\tif method[0] != '/' {\n\t\tmethod = \"/\" + method\n\t}\n\tmethodDesc := c.mds[method]\n\tif methodDesc == nil {\n\t\treturn grpcReq, fmt.Errorf(\"method %q not found in file descriptors\", method)\n\t}\n\n\tp, err := newCallParams(c.vu, params)\n\tif err != nil {\n\t\treturn grpcReq, fmt.Errorf(\"invalid GRPC's client.invoke() parameters: %w\", err)\n\t}\n\n\t// k6 GRPC Invoke's default timeout is 2 minutes\n\tif p.Timeout == time.Duration(0) {\n\t\tp.Timeout = 2 * time.Minute\n\t}\n\n\tif req == nil {\n\t\treturn grpcReq, errors.New(\"request cannot be nil\")\n\t}\n\n\tobject := req.ToObject(c.vu.Runtime())\n","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/grpc/client.go#L348-L384","documentation":"client.invoke() looks up the method name (auto-prefixed with '/' if missing) in the descriptor map built only by client.load() or connect(reflect: true); a miss yields 'method %q not found in file descriptors' (internal/js/modules/k6/grpc/client.go:366). The connection is fine - the method simply was never registered: wrong fully-qualified name, or the loaded descriptors do not contain that service.","triggerScenarios":"client.invoke('myapp.Users/GetUser') with wrong package, service, or method casing; a protoset built without --include_imports so the service's proto is missing; calling invoke on a client that never called load() and connected without reflect.","commonSituations":"Protobuf package names differing from directory names; protosets generated from the wrong .proto file; methods renamed server-side after the protoset was generated; examples copied from other projects with different package names.","solutions":["client.load() returns the parsed methods - log it and copy the exact FullMethod ('/package.Service/Method') into invoke","Regenerate the protoset including imports: protoc --include_imports --descriptor_set_out=...","Or connect with reflect: true to register the server's live method list"],"exampleFix":"// before\nclient.invoke('users.User/GetUser'); // wrong package\n\n// after\nconst methods = client.load('./pb/service.protoset');\nconsole.log(JSON.stringify(methods.map(m => m.FullMethod))); // copy exact name\nclient.invoke('/myapp.users.UserService/GetUser');","handlingStrategy":"validation","validationCode":"const methods = client.load('./pb/service.protoset');\nconst known = new Set(methods.map(m => m.FullMethod));\nfunction invokeKnown(method, req, params) {\n  const full = method.startsWith('/') ? method : '/' + method;\n  if (!known.has(full)) throw new Error(`unknown method ${full}; known: ${[...known].join(', ')}`);\n  return client.invoke(full, req, params);\n}","typeGuard":null,"tryCatchPattern":"try { client.invoke(m, req); } catch (e) { if (/not found in file descriptors/.test(e.message)) { /* log the load() result and fix the method name; not retryable as-is */ } throw e; }","preventionTips":["Derive method names from the load() return value, not from memory","Compile protosets with --include_imports","Call load() (or connect with reflect) before any invoke"],"tags":["grpc","k6","method-not-found","protobuf","invoke"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}