Skip to content

idtoken.NewClient panics if http.DefaultTransport is not a *http.Transport #3260

@vorporeal

Description

@vorporeal

I tried to set up our application so that all outbound HTTP requests would produce OTel traces.

Specifically, I added this code to our initialization logic:

http.DefaultTransport = otelhttp.NewTransport(http.DefaultTransport)

Unfortunately, this led to panics from idtoken.NewClient(), due to this code:

httpTransport := http.DefaultTransport.(*http.Transport).Clone()
httpTransport.MaxIdleConnsPerHost = 100

Given the fact that http.DefaultTransport has type http.RoundTripper (an interface) and not *http.Transport (a concrete type), I think this code should be doing more cautious type-checking to avoid panics here.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions