{"record":{"id":"85f6aa3d205d85fe","repo":"projectdiscovery/nuclei","slug":"failed-to-build-request-parser-w","errorCode":null,"errorMessage":"failed to build request parser: %w","messagePattern":"failed to build request parser: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/libs/grpc/invoke.go","lineNumber":138,"sourceCode":"\tcleanup := func() { refClient.Reset() }\n\treturn grpcurl.DescriptorSourceFromServer(ctx, refClient), cleanup, nil\n}\n\n// invokeUnary invokes a unary (or single-response) gRPC method described by src\n// over cc, marshaling the JSON request and formatting the JSON response.\nfunc invokeUnary(ctx context.Context, src grpcurl.DescriptorSource, cc *grpc.ClientConn, method, requestJSON string, headers []string) (string, error) {\n\tbody := strings.TrimSpace(requestJSON)\n\tif body == \"\" {\n\t\tbody = \"{}\"\n\t}\n\tvar in io.Reader = strings.NewReader(body)\n\n\tparser, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.FormatJSON, src, in, grpcurl.FormatOptions{\n\t\tEmitJSONDefaultFields: true,\n\t\tAllowUnknownFields:    false,\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to build request parser: %w\", err)\n\t}\n\n\tvar out bytes.Buffer\n\thandler := &grpcurl.DefaultEventHandler{\n\t\tOut:       &out,\n\t\tFormatter: formatter,\n\t}\n\n\tif err := grpcurl.InvokeRPC(ctx, src, cc, method, headers, handler, parser.Next); err != nil {\n\t\treturn \"\", err\n\t}\n\tif handler.Status != nil && handler.Status.Code() != codes.OK {\n\t\treturn \"\", fmt.Errorf(\"grpc status %s: %s\", handler.Status.Code().String(), handler.Status.Message())\n\t}\n\treturn strings.TrimRight(out.String(), \"\\n\"), nil\n}\n\n// describeSymbol returns the textual descriptor for a fully-qualified symbol.","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/grpc/invoke.go#L120-L156","documentation":"grpcurl.RequestParserAndFormatter could not be built for the request message. The parser is created with AllowUnknownFields=false and FormatJSON, so syntactically invalid JSON, or JSON containing fields that do not exist in the method's request schema, fails at this point; an unresolvable input type for the method also surfaces here.","triggerScenarios":"client.Invoke('acme.v1.Svc/Get', \"{'id': 1}\") (single quotes / trailing comma); message fields not present in the .proto ('{\"user_id\":1}' when the field is 'userId'); wrong method name so the request type cannot be resolved from the descriptor source.","commonSituations":"Hand-writing request JSON instead of copying field names from DescribeSymbol; schema drift between the protoset/reflection schema and the one the author inspected; JSON built by string concatenation instead of JSON.stringify.","solutions":["Pass strict JSON with schema-exact field names: client.Invoke('grpc.health.v1.Health/Check', '{\"service\":\"\"}')","Inspect the schema first: const d = client.DescribeSymbol('acme.v1.Svc/Get') and copy field names/types exactly","Use '{}' when no fields need setting (an empty message is already defaulted to {})"],"exampleFix":"// before: single-quoted pseudo-JSON and wrong field name\nclient.Invoke('acme.v1.User/Get', \"{'id': 1}\");\n\n// after: strict JSON with the field name from DescribeSymbol\nclient.Invoke('acme.v1.User/Get', JSON.stringify({ userId: 1 }));","handlingStrategy":"validation","validationCode":"let body = {};\ntry {\n  body = message ? JSON.parse(message) : {};\n} catch (e) {\n  throw new Error(`request is not strict JSON: ${e.message}`);\n}\nconst resp = client.Invoke(method, JSON.stringify(body));","typeGuard":"const isStrictJson = (s) => { try { JSON.parse(s); return true; } catch { return false; } };","tryCatchPattern":"try { const resp = client.Invoke(method, msg); }\ncatch (e) {\n  if (/failed to build request parser/.test(e.message || '')) {\n    // fix JSON syntax, then verify field names against DescribeSymbol output\n  }\n}","preventionTips":["Build request bodies with JSON.stringify from objects, never string concatenation","Copy field names exactly from DescribeSymbol before writing the message","Remember unknown fields are rejected (AllowUnknownFields=false) — no extra keys"],"tags":["grpc","json","validation","javascript"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}