Commit 7fd6522
fix(http): set User-Agent on the shared reqwest client (#1580)
`stack push` (and every other GitHub-backed command) has been
failing intermittently with `403 Request forbidden by
administrative rules` because GitHub's REST API rejects requests
that don't carry a User-Agent header, and `reqwest::Client::
builder()` doesn't set one by default. Symptom in production:
$ mergify stack push
mergify: HTTP 403 Forbidden:
Request forbidden by administrative rules. Please make sure
your request has a User-Agent header
(https://docs.github.com/en/rest/overview/resources-in-the-
rest-api#user-agent-required).
Fix: configure the shared `Client` with `User-Agent:
mergify-cli/<crate-version>`. The header value uses Cargo's
package version (the placeholder `0.0.0` in dev, the stamped
calver in release builds via the upcoming version-from-tag PR);
GitHub only cares that the header is present and identifies the
client, not the format of the value.
Add a wiremock test that pins the header so dropping the
`.user_agent(...)` call again surfaces as a test failure
instead of a prod 403.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 5df5940 commit 7fd6522
1 file changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| |||
111 | 118 | | |
112 | 119 | | |
113 | 120 | | |
| 121 | + | |
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| |||
479 | 487 | | |
480 | 488 | | |
481 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
482 | 513 | | |
483 | 514 | | |
484 | 515 | | |
| |||
0 commit comments