Commit db92d58
authored
[log] log(envutil): add debug logging to env var parse fallbacks (#3825)
## Summary
Adds debug logging to `internal/envutil/envutil.go` to surface
misconfiguration earlier.
## What changed
Added `var logEnvUtil = logger.New("envutil:envutil")` and three
targeted `logEnvUtil.Printf` calls — one in each type-converting
function — that fire only when an environment variable is **set but
unusable**:
| Function | Log condition |
|---|---|
| `GetEnvInt` | Value is set but not a valid positive integer |
| `GetEnvDuration` | Value is set but not a valid positive duration |
| `GetEnvBool` | Value is set but not a recognised boolean
(`1/true/yes/on` / `0/false/no/off`) |
The `GetEnvString` function is intentionally not logged — it has no
parse step and adding a log there would be too noisy.
## Why
When an operator sets e.g. `MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD=512k` (an
invalid integer), the gateway silently falls back to the default with no
indication of what happened. With this change, enabling
`DEBUG=envutil:*` reveals the problem immediately:
```
envutil:envutil GetEnvInt: MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD="512k" is not a valid positive integer, using default=524288
```
## Quality checklist
- [x] Exactly 1 file modified
- [x] No test files modified
- [x] Logger declaration added (`var logEnvUtil =
logger.New("envutil:envutil")`)
- [x] Logger naming follows `pkg:filename` convention (matches
`logGitHub`/`logExpand` in the same package)
- [x] Logger arguments use only in-scope variables — no side effects
- [x] Log messages are meaningful and actionable
- [x] No duplication of existing logs
- [x] Import statements follow Go formatting conventions
> Generated by [Go Logger
Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/24437444913/agentic_workflow)
· ● 4.8M ·
[◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+go-logger%22&type=pullrequests)
<!-- gh-aw-agentic-workflow: Go Logger Enhancement, engine: copilot,
model: auto, id: 24437444913, workflow_id: go-logger, run:
https://github.com/github/gh-aw-mcpg/actions/runs/24437444913 -->
<!-- gh-aw-workflow-id: go-logger -->1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | | - | |
34 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
| |||
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| 65 | + | |
57 | 66 | | |
58 | 67 | | |
59 | 68 | | |
0 commit comments