This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid nil pointer error when debugging requests with no body (#176)
@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.
- Loading branch information