Skip to content

fix: send a User-Agent on every outbound request - #19

Merged
CodeWithJuber merged 1 commit into
mainfrom
fix/http-user-agent
Aug 13, 2026
Merged

fix: send a User-Agent on every outbound request#19
CodeWithJuber merged 1 commit into
mainfrom
fix/http-user-agent

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

Found by calling github.get_repo through a live MCP session.

reqwest sends no User-Agent by default, and GitHub rejects requests without one:

403 Request forbidden by administrative rules. Please make sure your request
has a User-Agent header

That is all 25 github operations failing before authentication is even considered. The failure mode is the expensive part: it surfaces as a generic network error, so it reads as a credential problem, and no amount of fixing the token makes it go away. Several WAF-fronted provider APIs reject UA-less traffic the same way.

Both Client::builder() call sites (new and with_timeout) were also duplicating timeout and redirect config. Collapsed into one build_client(timeout_secs) so a future transport setting cannot be added to one path and forgotten on the other.

The UA is connector-hub/<CARGO_PKG_VERSION> (+https://github.com/CodeWithJuber/connector-hub) — version comes from the crate, so it tracks releases without a second place to update.

Verification

Same operation, same credentials, before and after:

before:  network error: HTTP error 403: Request forbidden by administrative rules...
after:   network error: HTTP error 401: {"message": "Bad credentials", ...}

401 is the correct answer here — that token is expired. The point is the request now reaches GitHub's auth layer at all.

cargo fmt --check                       ok
cargo clippy --all-targets -D warnings  ok
cargo test --workspace                  26 passed
connector-hub validate                  passed

🤖 Generated with Claude Code

https://claude.ai/code/session_018Xs4hZtZhd9Vi6EJnVnwDf

reqwest sends no User-Agent by default. GitHub rejects such requests outright:

  403 Request forbidden by administrative rules. Please make sure your
  request has a User-Agent header

That is every one of the 25 github operations failing before authentication is
even considered — the error looks like a credential problem and is not one.
Several WAF-fronted provider APIs behave the same way, so this is not cosmetic.

Both client builders now go through one `build_client`, which sets
`connector-hub/<version> (+repo url)`. Verified against the live API: the same
call that returned 403 now returns 401 Bad credentials, which is the expired
token doing its job.
@CodeWithJuber
CodeWithJuber merged commit 277ce9d into main Aug 13, 2026
4 checks passed
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