Commit 0e5e4c4
authored
refactor: consolidate duplicate DIFC filtered-item struct and tagsToStrings (#2111)
Two duplication patterns introduced in `internal/server/difc_log.go`
required parallel edits across files when modifying DIFC filter event
data shapes.
## Changes
- **Struct consolidation** — `FilteredItemLogEntry` (server) and
`JSONLFilteredItem` (logger) shared identical 11-field data definitions.
Moved the shared fields into a new `logger.FilteredItemLogEntry`;
`JSONLFilteredItem` now embeds it, keeping only its own `Timestamp` and
`Type` fields:
```go
// Before: 11 fields duplicated verbatim in both structs
type JSONLFilteredItem struct {
Timestamp string `json:"timestamp"`
Type string `json:"type"`
ServerID string `json:"server_id"`
// ... 9 more duplicated fields
}
// After: embed the shared struct
type JSONLFilteredItem struct {
Timestamp string `json:"timestamp"`
Type string `json:"type"`
FilteredItemLogEntry
}
```
- **Remove `toJSONLFilteredItem()`** — field-by-field copy method
replaced with a direct struct literal:
`&logger.JSONLFilteredItem{FilteredItemLogEntry: entry}`
- **Eliminate duplicate `tagsToStrings`** — local helper in
`difc_log.go` was identical to `difc.TagsToStrings`; replaced all call
sites with the canonical package function
- **Test updates** — `difc_log_test.go` updated to reference
`logger.FilteredItemLogEntry` instead of the removed local type
> [!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-build3728142662/b332/launcher.test
/tmp/go-build3728142662/b332/launcher.test
-test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt
-test.paniconexit0 -test.timeout=10m0s rev-�� /unix` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3728142662/b317/config.test
/tmp/go-build3728142662/b317/config.test
-test.testlogfile=/tmp/go-build3728142662/b317/testlog.txt
-test.paniconexit0 -test.timeout=10m0s rev-�� ache/go/1.25.8/x-p
cf9O/V70NMeR5oSymain x_amd64/vet` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3728142662/b332/launcher.test
/tmp/go-build3728142662/b332/launcher.test
-test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt
-test.paniconexit0 -test.timeout=10m0s rev-�� /unix` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3728142662/b332/launcher.test
/tmp/go-build3728142662/b332/launcher.test
-test.testlogfile=/tmp/go-build3728142662/b332/testlog.txt
-test.paniconexit0 -test.timeout=10m0s rev-�� /unix` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3728142662/b341/mcp.test
/tmp/go-build3728142662/b341/mcp.test
-test.testlogfile=/tmp/go-build3728142662/b341/testlog.txt
-test.paniconexit0 -test.timeout=10m0s rev-��
ache/go/1.25.8/x64/src/runtime/cgo1.25.8` (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 -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.File tree
3 files changed
+24
-60
lines changed- internal
- logger
- server
3 files changed
+24
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| |||
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 11 | | |
30 | 12 | | |
31 | 13 | | |
| |||
40 | 22 | | |
41 | 23 | | |
42 | 24 | | |
43 | | - | |
| 25 | + | |
44 | 26 | | |
45 | 27 | | |
46 | 28 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
50 | 32 | | |
51 | 33 | | |
52 | 34 | | |
53 | 35 | | |
54 | 36 | | |
55 | 37 | | |
56 | 38 | | |
57 | | - | |
58 | | - | |
| 39 | + | |
| 40 | + | |
59 | 41 | | |
60 | 42 | | |
61 | 43 | | |
| |||
71 | 53 | | |
72 | 54 | | |
73 | 55 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 56 | | |
102 | 57 | | |
103 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
0 commit comments