Commit 8c72d41
authored
fix: add retry with exponential backoff to schema fetch for transient HTTP errors (#2582)
Gateway startup fails when `raw.githubusercontent.com` rate-limits the
JSON config schema fetch (HTTP 429). Any transient error was treated as
fatal with no retry.
## Changes
**`internal/config/validation_schema.go`**
- Added `isTransientHTTPError()` identifying 429, 503, and all 5xx codes
- `fetchAndFixSchema()` now retries up to `maxSchemaFetchRetries` (3)
times with exponential backoff (1s → 2s) for transient errors; permanent
errors (4xx except 429) fail immediately
- `schemaFetchRetryDelay` and `schemaHTTPClientTimeout` are
package-level vars so tests can zero them out without sleeps
**`internal/config/validation_schema_fetch_test.go`**
- `init()` sets zero delay + 200ms HTTP timeout for all tests in the
file
- `TestFetchAndFixSchema_HTTPError` extended with 429 case and
per-error-type request-count assertions (1 request for permanent, 3 for
transient)
- Added `TestFetchAndFixSchema_RetrySucceedsAfterTransientError`: 2×429
→ 200 succeeds
- Added `TestFetchAndFixSchema_ExponentialBackoffDelays`: verifies
exactly `maxSchemaFetchRetries` requests are made on persistent
transient failure
**Note**: The secrecy-vs-integrity notice labeling fix (Problem 2 from
the issue) is already present in the codebase (`difcPolicyLabel()` +
`IsSecrecyViolation` in `difc_log.go` / `difc/resource.go`).
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `example.com`
> - Triggering command: `/tmp/go-build3732201295/b330/launcher.test
/tmp/go-build3732201295/b330/launcher.test
-test.testlogfile=/tmp/go-build3732201295/b330/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a --global git
pull.rebase abis` (dns block)
> - Triggering command: `/tmp/go-build63582137/b334/launcher.test
/tmp/go-build63582137/b334/launcher.test
-test.testlogfile=/tmp/go-build63582137/b334/testlog.txt
-test.paniconexit0 -test.timeout=10m0s` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3732201295/b315/config.test
/tmp/go-build3732201295/b315/config.test
-test.testlogfile=/tmp/go-build3732201295/b315/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true -c=4 -nolocalimports
-importcfg /tmp/go-build3732201295/b287/importcfg -pack
/home/REDACTED/go/pkg/mod/github.com/modelcontextprotocol/go-sdk@v1.4.1/auth/auth.go
/home/REDACTED/go/pkg/mod/github.com/modelcontextprotocol/go-sdk@v1.4.1/auth/client.go
ortc�� go 9p-W5oE9v ache/go/1.25.8/x64/pkg/tool/linu-Werror
credential.helpe/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile`
(dns block)
> - Triggering command: `/tmp/go-build2566417517/b001/config.test
/tmp/go-build2566417517/b001/config.test
-test.testlogfile=/tmp/go-build2566417517/b001/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.run=TestFetchAndFixSchema
-test.v=true ache/go/1.25.8/x64/src/crypto/ec-ifaceassert x_amd64/vet -p
internal/reflectdocker-cli-plugin-metadata -lang=go1.25 x_amd64/vet ap
2201295/b171=/tmp/go-build .cfg 64/pkg/tool/linux_amd64/vet -p
ache/go/1.25.8/x-c -lang=go1.25 64/pkg/tool/linux_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build1075949314/b001/config.test
/tmp/go-build1075949314/b001/config.test
-test.testlogfile=/tmp/go-build1075949314/b001/testlog.txt
-test.paniconexit0 -test.run=TestFetchAndFixSchema -test.v=true
-test.timeout=30s SkhS/x3QNW0bkE1zmain 64/pkg/tool/linu-lang=go1.25 -I
/tmp/go-build373docker-cli-plugin-metadata -I
64/pkg/tool/linu-dwarf=false 2201�� azero@v1.11.0/ingo1.25.8
azero@v1.11.0/in-c=4 64/pkg/tool/linu-nolocalimports 2201295/b165/
/dev/null ctor
64/pkg/tool/linu/tmp/go-build3732201295/b345/_testmain.go` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3732201295/b330/launcher.test
/tmp/go-build3732201295/b330/launcher.test
-test.testlogfile=/tmp/go-build3732201295/b330/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a --global git
pull.rebase abis` (dns block)
> - Triggering command: `/tmp/go-build63582137/b334/launcher.test
/tmp/go-build63582137/b334/launcher.test
-test.testlogfile=/tmp/go-build63582137/b334/testlog.txt
-test.paniconexit0 -test.timeout=10m0s` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3732201295/b330/launcher.test
/tmp/go-build3732201295/b330/launcher.test
-test.testlogfile=/tmp/go-build3732201295/b330/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a --global git
pull.rebase abis` (dns block)
> - Triggering command: `/tmp/go-build63582137/b334/launcher.test
/tmp/go-build63582137/b334/launcher.test
-test.testlogfile=/tmp/go-build63582137/b334/testlog.txt
-test.paniconexit0 -test.timeout=10m0s` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3732201295/b339/mcp.test
/tmp/go-build3732201295/b339/mcp.test
-test.testlogfile=/tmp/go-build3732201295/b339/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo
committer.name x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build63582137/b343/mcp.test
/tmp/go-build63582137/b343/mcp.test
-test.testlogfile=/tmp/go-build63582137/b343/testlog.txt
-test.paniconexit0 -test.timeout=10m0s ortc�� TOKEN"; }; f get
TOKEN"; }; f get ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
-pthread telabs/wazero -fmessage-length=0
ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -I eNqb/Hpbq2t4bcSrSRPw9eNqb
-I x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT CODING AGENT TIPS -->
---
📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs),
[Azure Boards](https://gh.io/cca-azure-boards-docs) or
[Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in
one click without leaving your project management tool.2 files changed
Lines changed: 159 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
19 | 41 | | |
20 | 42 | | |
21 | 43 | | |
| |||
83 | 105 | | |
84 | 106 | | |
85 | 107 | | |
86 | | - | |
| 108 | + | |
87 | 109 | | |
88 | 110 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
94 | 151 | | |
95 | | - | |
96 | | - | |
97 | 152 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 153 | + | |
| 154 | + | |
101 | 155 | | |
| 156 | + | |
| 157 | + | |
102 | 158 | | |
103 | 159 | | |
104 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
58 | 67 | | |
59 | 68 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
68 | 79 | | |
69 | 80 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
78 | 97 | | |
79 | 98 | | |
80 | 99 | | |
81 | 100 | | |
82 | 101 | | |
| 102 | + | |
83 | 103 | | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
| |||
90 | 111 | | |
91 | 112 | | |
92 | 113 | | |
| 114 | + | |
| 115 | + | |
93 | 116 | | |
94 | 117 | | |
95 | 118 | | |
| |||
108 | 131 | | |
109 | 132 | | |
110 | 133 | | |
111 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
112 | 137 | | |
113 | | - | |
| 138 | + | |
114 | 139 | | |
115 | 140 | | |
116 | 141 | | |
| |||
589 | 614 | | |
590 | 615 | | |
591 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
0 commit comments