googleapis / googleapis/gapic-showcase

large http payload issue

Open
#1,330 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
183
Forks
55
Avg merge
1d 1h
Merged PRs (30d)
8

Description

While trying the project, I made an http request with a large payload with post and got an error like
`{"error":{"code":400,"message":"error reading body params '*': proto: syntax error (line 2:12): invalid character '\\x00' in string","details":null,"Body":"","Header":null,"Errors":null}}%`

this line needs all bytes to unmarshall
https://github.com/googleapis/gapic-showcase/blob/8186605bbe3c9202b8313f692e279ab2c4faf156/util/genrest/goviewcreator.go#L128

after some debugging and reproducing bug on simple go server i've found out this, giving r.body directly to teereader wont be able to read all data.

https://github.com/googleapis/gapic-showcase/blob/8186605bbe3c9202b8313f692e279ab2c4faf156/util/genrest/goviewcreator.go#L121

image
image
image

red dots are null bytes \\x00

> TeeReader returns a Reader that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.

https://cs.opensource.google/go/go/+/go1.20.5:src/io/io.go;l=603

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.