bosprimigenious opened a new issue, #893:
URL: https://github.com/apache/hugegraph-toolchain/issues/893
### Bug Type
exception / error in Go client request logging
### Before submit
- [x] Searched open/closed issues and pull requests for ContentLength,
unknown length, request body, hgtransport and Go logging; no overlapping fix
found. Existing #805 adds ordinary-length logger tests. This is separate from
#748/#772 compatibility fixtures and benchmarks.
### Environment
- Toolchain master: 0be65bffbd7ff1ba3d9564e3561c7220469fddc5
- Go 1.25.14, macOS arm64; go.mod/go.sum unchanged
- Server: local net/http/httptest echo server; no HugeGraph server needed
### Expected & Actual behavior
Go net/http.Request documents ContentLength=-1 as an unknown length (0 with
a non-nil client Body is also unknown). Enabling request-body logging should
preserve transmission. Instead Client.Perform constructs a slice with capacity
-1 and panics before RoundTrip. Disabling body logging sends the same request
successfully.
Run this program from hugegraph-client-go (`go run /path/to/mre.go`):
```go
package main
import (
"io"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"fmt"
"github.com/apache/hugegraph-toolchain/hugegraph-client-go/hgtransport"
)
func main() {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter,r
*http.Request){ b,_:=io.ReadAll(r.Body); w.Write(b) })); defer s.Close()
u,_ := url.Parse(s.URL)
c :=
hgtransport.New(hgtransport.Config{URL:u,Logger:&hgtransport.TextLogger{Output:io.Discard,EnableRequestBody:true}})
r,_ :=
http.NewRequest("POST","/gremlin",io.NopCloser(strings.NewReader(`{"gremlin":"g.V()"}`)))
r.ContentLength = -1
response,err := c.Perform(r); if err != nil {panic(err)}; defer
response.Body.Close()
b,_:=io.ReadAll(response.Body); fmt.Println(string(b))
}
```
Actual on the unmodified base:
```text
panic: runtime error: makeslice: cap out of range
.../hgtransport.(*Client).Perform ... hgtransport.go:120
```
Expected: print `{"gremlin":"g.V()"}`.
### Vertex/Edge example and Schema
Not applicable: transport-level failure before a graph server request.
### Proposed fix and verification
Use a zero-value bytes.Buffer for the existing body duplication instead of
treating ContentLength as an allocation capacity. A real HTTP regression matrix
for -1/0/exact length and body logging off/on gives 1 failing and 5 passing
cases on the base, all 6 pass with this one-line fix. Existing hgtransport
tests/race and module build pass. Full module API tests need an actual
HugeGraph service and have not passed locally; repository-wide header check
also fails on local .git metadata (changed-file header check passes).
AI disclosure: this reproduction, analysis and text were prepared with
OpenAI Codex. No human review or end-to-end HugeGraph server verification is
claimed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]