Commit 056b712
authored
Deduplicate MCP_GATEWAY_SESSION_TIMEOUT env-var lookup into shared getSessionTimeout() (#5100)
`envutil.GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour)` was
inlined in `transport.go` despite `routed.go` already owning an
identical wrapper — two places to update if the env-var key or default
ever changes.
## Changes
- **`routed.go`** — Rename `getRoutedSessionTimeout()` →
`getSessionTimeout()`; update its doc comment to reflect shared
ownership
- **`transport.go`** — Replace inline literal with
`getSessionTimeout()`; drop now-unused `envutil` and `time` imports
- **`routed_test.go`** — Update
`TestRoutedModeSessionTimeout_ReadsEnvVar` call sites to the new name;
test coverage is unchanged
```go
// Before — transport.go inlined the literal independently
SessionTimeout: envutil.GetEnvDuration("MCP_GATEWAY_SESSION_TIMEOUT", 6*time.Hour),
// After — both callers share one function
SessionTimeout: getSessionTimeout(),
```
> [!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-build602771692/b513/launcher.test
/tmp/go-build602771692/b513/launcher.test
-test.testlogfile=/tmp/go-build602771692/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo
/tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet
go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet` (dns
block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build602771692/b495/config.test
/tmp/go-build602771692/b495/config.test
-test.testlogfile=/tmp/go-build602771692/b495/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build602771692/b365/vet.cfg Ua_e/htfOW-jx_xLgo1.25.9
ache/go/1.25.9/x-c=4 x_amd64/vet 0276810/b172/ go.opentelemetry-atomic`
(dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build602771692/b513/launcher.test
/tmp/go-build602771692/b513/launcher.test
-test.testlogfile=/tmp/go-build602771692/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo
/tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet
go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet` (dns
block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build602771692/b513/launcher.test
/tmp/go-build602771692/b513/launcher.test
-test.testlogfile=/tmp/go-build602771692/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build602771692/b428/vet.cfg ache/go/1.25.9/x64/src/runtime/cgo
/tmp/go-build3583632305/b314/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet
go_.�� 64/src/net -I x_amd64/vet --gdwarf-5 ions =0 x_amd64/vet` (dns
block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build602771692/b522/mcp.test
/tmp/go-build602771692/b522/mcp.test
-test.testlogfile=/tmp/go-build602771692/b522/testlog.txt
-test.paniconexit0 -test.timeout=10m0s` (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>3 files changed
Lines changed: 13 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
820 | | - | |
| 819 | + | |
| 820 | + | |
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
826 | | - | |
| 825 | + | |
| 826 | + | |
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
831 | | - | |
| 831 | + | |
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
| |||
0 commit comments