equinix-labs / metal-go

[Deprecated] Golang client for Equinix Metal
https://deploy.equinix.com/labs/equinix-sdk-go/
MIT License
3 stars 2 forks source link

fix: avoid nil pointer error when debugging requests with no body #176

Closed ctreatma closed 11 months ago

ctreatma commented 11 months ago

@cprivitere reported that cluster-api-provider-packet experiences nil pointer errors when debugging is enabled and a request has no body. This behavior seems to have started in v0.25.1, which introduced automatic auth token redaction in debug output.

In order to redact the auth token without impacting the original request, we were cloning the request object. In order to clone the request body, we had to call request.GetBody(), but that function causes a nil pointer error if the request body is nil.

This updates the auth token redaction code to temporarily overwrite the auth token in the original request, rather than cloning the request & its potentially-nil body.

cprivitere commented 11 months ago

Can confirm this change avoids the nil pointer error I was getting in CAPP.

github-actions[bot] commented 11 months ago

This PR is included in version 0.28.0 :tada: