hashicorp / hashicorp/go-retryablehttp

Using custom logger type causes panic at runtime

Open
#243 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
298
PR merge metrics
No merged PRs in 30d

Description

ref: [main/client.go](https://github.com/hashicorp/go-retryablehttp/blob/main/client.go#L458-L464)

Hey all. Can we Update the `retryablehttp.Client.Logger` field to be one of the following?

1. A composite interface (ala go 1.18+ generics)?

```
type RetryableHttpLoggerConstraint interface {
retryablehttp.Logger | retryablehttp.LeveledLogger
}
func SetLogger[T LoggerConstraint](client *retryablehttp.Client, logger T) {
client.Logger = logger
}
```

2. A single interface (`retryablehttp.LeveledLogger` __*or*__ `retryablehttp.Logger` __*or*__ something else)

Doing a type check and panic-ing at runtime is no bueno and is likely to cause incidents in production (like it did with us).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.