Commit f72afef
authored
[log] Add debug logging to guard policy JSON unmarshaling (#3733)
## Summary
Adds 5 targeted `logGuardPolicy` debug log calls to
`internal/config/guard_policy.go` — previously unlogged but important
functions in the DIFC guard policy parsing pipeline.
## Changes
**File:** `internal/config/guard_policy.go`
Three functions now have debug logging:
### `GuardPolicy.UnmarshalJSON`
- Logs parsed key count after initial JSON decode (helps diagnose
unexpected policy structures)
- Logs resolved policy type (`allow-only` vs `write-sink`) before
returning
### `AllowOnlyPolicy.UnmarshalJSON`
- Logs field count on entry (visibility into how many fields are being
parsed)
- Logs parsed `repos` type and `minIntegrity` value on successful parse
### `normalizeAndValidateScopeArray`
- Logs scope entry count before validation loop begins
## Quality
- ✅ Exactly 1 file modified (focused PR)
- ✅ No test files modified
- ✅ Reuses existing `logGuardPolicy = logger.New("config:guard_policy")`
logger — no new declaration added
- ✅ Logger naming follows `pkg:filename` convention (already established
in the file)
- ✅ No side effects in logger arguments — only pre-computed values
(`len(raw)`, `p.MinIntegrity`, etc.)
- ✅ Messages are meaningful and helpful for troubleshooting policy parse
failures
- ✅ No duplication with existing log calls
## Context
`guard_policy.go` is 800 lines with complex DIFC guard policy
parsing/validation logic. The `UnmarshalJSON` functions are called
during gateway startup and whenever policy JSON is parsed. These are the
first places where malformed configs would fail, making entry/exit
logging particularly useful for diagnosing configuration issues.
> Generated by [Go Logger
Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/24381958087/agentic_workflow)
· ● 9M ·
[◷](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: 24381958087, workflow_id: go-logger, run:
https://github.com/github/gh-aw-mcpg/actions/runs/24381958087 -->
<!-- gh-aw-workflow-id: go-logger -->1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
| |||
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| 132 | + | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
| |||
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
| 184 | + | |
177 | 185 | | |
178 | 186 | | |
179 | 187 | | |
| |||
477 | 485 | | |
478 | 486 | | |
479 | 487 | | |
| 488 | + | |
480 | 489 | | |
481 | 490 | | |
482 | 491 | | |
| |||
0 commit comments