Repository navigation
fix(http): preserve repeated request configuration values - #3625
as992949791 wants to merge 2 commits into
Conversation
notlakshitha
left a comment
There was a problem hiding this comment.
the list headers look good, and the new test passes. but the boolean headers right next to them still use r.Header.Get, which only reads the first field line: readonly at request_config.go:24, lockdown at :39 and insiders at :49. this case matters more than the list headers because it fails open. if a client sends X-MCP-Readonly: false and a proxy adds X-MCP-Readonly: true, the server ends up not read-only:
X-MCP-Readonly: [false,true] -> readonly=false
X-MCP-Lockdown: [false,true] -> lockdown=false
(that's from a quick test on this branch.) for readonly/lockdown I'd treat it as enabled if any field line is truthy, e.g. slices.ContainsFunc(r.Header.Values(h), relaxedParseBool), and add those to the repeated-header test.
small one too: the query fallback at :59 still uses query.Get("features"), so ?features=a&features=b gives [a]. if repeated headers get merged now, joining query["features"] would make the two paths behave the same.
There was a problem hiding this comment.
🟢 Approval recommended
The review found no active issues, and the added middleware regression coverage addresses repeated header/query values and feature-precedence behavior.
No open issues 🎉
What changed in this PR
This pull request updates HTTP request-configuration parsing so repeated field lines retain all configured list and boolean values, matching equivalent comma-separated input. It also adds regression coverage for repeated headers, query parameters, and feature precedence.
Changes:
- Combine repeated list-valued request headers before parsing.
- Preserve repeated query values and evaluate repeated boolean configuration headers consistently.
- Add table-driven middleware tests for repeated values and header/query precedence.
| File | Summary |
|---|---|
pkg/http/middleware/request_config.go |
Preserves repeated request-configuration header and query values during middleware parsing. |
pkg/http/middleware/request_config_test.go |
Adds regression coverage for repeated list, boolean, query, and feature-precedence behavior. |
Review effort: Lite (auto)
|
Addressed in 4b907e3. Readonly, lockdown, and insiders now check every field line with the existing relaxed boolean parser and enable if any is truthy. Repeated feature query parameters are combined; a present features header still takes precedence, including an empty header. The added regressions fail on the previous PR head and pass with the fix. Middleware race tests, native lint ( |
Summary
Preserve all values in repeated request configuration headers and feature query parameters. Boolean modes enable when any field line is truthy, so a later readonly or lockdown restriction takes effect.
Why
Reading only the first field line discarded later tool selections, exclusions, feature flags, and boolean restrictions. For example, readonly fields
[false, true]previously left readonly disabled, and?features=a&features=bselected onlya.Fixes #3624.
What changed
MCP impact
Prompts tested (tool changes only)
Not applicable. Tests exercise HTTP middleware without calling live APIs or tools.
Security / limits
Tool renaming
Lint & tests
bash ./script/lint— 0 issues (golangci-lint 2.14.0, Go 1.27.3).bash ./script/test— fullgo test -race ./...passed after lint.go test -race -count=1 ./pkg/http/middleware -vandgit diff --checkpassed.Evidence
Docs
Merge Danger
Door: two-way. Blast Radius: request configuration.
Prepared with AI assistance (Codex). All listed checks were executed locally.