8000 fix(http): preserve case-insensitive header precedence by feiiiiii5 · Pull Request #4417 · googleapis/mcp-toolbox · GitHub
[go: up one dir, main page]

Skip to content

fix(http): preserve case-insensitive header precedence - #4417

Open
feiiiiii5 wants to merge 1 commit into
googleapis:mainfrom
feiiiiii5:codex/http-header-precedence
Open

feiiiiii5 wants to merge 1 commit into
googleapis:mainfrom
feiiiiii5:codex/http-header-precedence

Conversation

@feiiiiii5
Copy link
Copy Markdown

Description

Fixes #4416.

HTTP header names with different casing survived source/tool/parameter merges as separate map keys. They were canonicalized only when setting the request headers, so map iteration could let a lower-priority value replace an override. Canonicalize names as each layer is merged, preserving source < tool < provided parameter precedence and existing values/parameter behavior.

Validation on Go 1.27.3 (darwin/arm64):

  • The new deterministic header regression fails on the original code. The related package passes all 22 scenarios with go test -race -p=2 -count=1 -v -cover ./internal/tools/http, including a real HTTP source, tool invocation and local receiver. Package coverage increases from 35.2% to 69.4%.
  • Scoped go vet, golangci-lint 2.15.0 and its goimports formatter pass. go.mod/go.sum are unchanged.

Repository-wide checks, the authenticated Google fixture and full MCP endpoint tests were not run.

PR Checklist

  • Reviewed CONTRIBUTING.md.
  • Opened the issue before writing code.
  • Reviewed the entire diff.
  • Related tests and linter pass (scope above).
  • Coverage does not decrease for the affected package.
  • Existing header-precedence documentation remains accurate.
  • No breaking change marker is needed.

@feiiiiii5
feiiiiii5 requested a review from a team as a code owner November 4, 2026 20:33
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces case-insensitive header merging and overriding in the HTTP tool. It replaces direct map copying with a new mergeHeaders helper function that canonicalizes header keys using http.CanonicalHeaderKey. Additionally, it adds comprehensive unit tests to verify header precedence and case-insensitive overrides. No review comments were provided, so I have no feedback to address.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP header precedence is lost when source and tool use different casing

2 participants

0