Fix nil input stream panic under Go jsonv2

This commit is contained in:
Scott Blum
2026-09-02 11:25:29 -04:00
parent cf21d4aca5
commit cfa6ff6886
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
package main
import (
"bytes"
"context"
"flag"
"fmt"
@@ -764,7 +765,7 @@ func main() {
// create a request to invoke an RPC
tmpl := grpcurl.MakeTemplate(dsc)
options := grpcurl.FormatOptions{EmitJSONDefaultFields: true}
_, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.Format(*format), descSource, nil, options)
_, formatter, err := grpcurl.RequestParserAndFormatter(grpcurl.Format(*format), descSource, bytes.NewReader(nil), options)
if err != nil {
fail(err, "Failed to construct formatter for %q", *format)
}
+1 -1
View File
@@ -128,7 +128,7 @@ func TestHandler(t *testing.T) {
verbose := verbosityLevel > 0
_, formatter, err := RequestParserAndFormatter(format, source, nil, FormatOptions{IncludeTextSeparator: !verbose})
_, formatter, err := RequestParserAndFormatter(format, source, bytes.NewReader(nil), FormatOptions{IncludeTextSeparator: !verbose})
if err != nil {
t.Errorf("Failed to create parser and formatter: %v", err)
continue