Skip to content

fix(github): keep configured HTTP client when no token is set - #649

Open
pcbeingused333 wants to merge 1 commit into
cashapp:masterfrom
pcbeingused333:fix/github-client-no-token
Open

pcbeingused333 wants to merge 1 commit into
cashapp:masterfrom
pcbeingused333:fix/github-client-no-token

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #-

github.New replaced the supplied *http.Client with http.DefaultClient whenever the token was empty, so the transport/timeout configured by the caller (newHTTPClient in app/main.go) was ignored for unauthenticated users. When a token was set, the wrapper also built a fresh http.Client, dropping Timeout and Jar.

Fix: only wrap the transport when there is a token, and do so on a shallow copy of the provided client so its other settings are preserved.

Tests (github/api_test.go): a sentinel transport and a timeout on the configured client must survive New with and without a token. Both fail on master and pass with the change.

Disclosure: this change was prepared with the help of an AI assistant (Claude) and submitted by a human contributor.

New discarded the provided client and used http.DefaultClient when the token was empty, and dropped Timeout/Jar when wrapping with a token. Copy the client instead.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant