Commit 1cd5306
authored
Centralize jq payload preview size configuration (#1066)
The jq middleware payload preview size (500 characters) was hardcoded in
multiple locations, making it difficult to adjust consistently.
## Changes
- **Added `PayloadPreviewSize` constant** in
`internal/middleware/jqschema.go`
- Replaces hardcoded `500` in preview truncation logic
- Replaces hardcoded `500` in logging statements
- Updates function documentation
- **Updated references** in documentation (`README.md`, `AGENTS.md`) and
tests to reference the constant
## Example
Before:
```go
truncated := len(payloadStr) > 500
if truncated {
preview = payloadStr[:500] + "..."
}
```
After:
```go
truncated := len(payloadStr) > PayloadPreviewSize
if truncated {
preview = payloadStr[:PayloadPreviewSize] + "..."
}
```
The constant provides a single point of configuration for payload
preview behavior across the middleware package.
> [!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-build3360590955/b279/launcher.test
/tmp/go-build3360590955/b279/launcher.test
-test.testlogfile=/tmp/go-build3360590955/b279/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 4047529/b162/_pkg_.a
64/src/runtime/cgo x_amd64/vet` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3360590955/b264/config.test
/tmp/go-build3360590955/b264/config.test
-test.testlogfile=/tmp/go-build3360590955/b264/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo
3E2y/lfIxJsLvVk-kDynw3E2y .12/x64/bin/as` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3360590955/b279/launcher.test
/tmp/go-build3360590955/b279/launcher.test
-test.testlogfile=/tmp/go-build3360590955/b279/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 4047529/b162/_pkg_.a
64/src/runtime/cgo x_amd64/vet` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3360590955/b279/launcher.test
/tmp/go-build3360590955/b279/launcher.test
-test.testlogfile=/tmp/go-build3360590955/b279/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 4047529/b162/_pkg_.a
64/src/runtime/cgo x_amd64/vet` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3360590955/b288/mcp.test
/tmp/go-build3360590955/b288/mcp.test
-test.testlogfile=/tmp/go-build3360590955/b288/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true se
4047529/b025/vet.cfg rgo/bin/as -p internal/msan -lang=go1.25
/opt/hostedtoolcache/go/1.25.7/x-trimpath go_.��
lcache/go/1.25.7/x64=/_/GOROOT Rd x_amd64/vet -p hash/maphash
-lang=go1.25 x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build1404549538/b001/mcp.test
/tmp/go-build1404549538/b001/mcp.test
-test.testlogfile=/tmp/go-build1404549538/b001/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -tes��
io.containerd.runtime.v2.task/moby/63201cdb6593143a21722511515a1/run/containerd/io.containerd.rugofmt
-test.timeout=10m0s k/gh-aw-mcpg/gh-aw-mcpg/awmg se
4047529/b025/vet--norc ffbfb0094a8a3294--noprofile
k/gh-aw-mcpg/gh-aw-mcpg/awmg -tes�� -test.paniconexit0 y
by/71af78b18fce5832ab10e180bbc3a77cfee5908e386c9517dcf943eeea458c34/log.json
ntime.v2.task/mo/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet
Rd t",
"REQUESTS_CA_B-c iginal` (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.4 files changed
Lines changed: 18 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
219 | 223 | | |
220 | 224 | | |
221 | 225 | | |
222 | | - | |
| 226 | + | |
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
| |||
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
340 | | - | |
| 344 | + | |
341 | 345 | | |
342 | 346 | | |
343 | | - | |
| 347 | + | |
344 | 348 | | |
345 | | - | |
346 | | - | |
347 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
0 commit comments