Skip to content

Cover stdio proxy protocol-version fallback - #7124

Merged
ChrisJBurns merged 2 commits into
stacklok:mainfrom
bharathvemula:toolhive-7119-regression-tests
Nov 25, 2026
Merged

ChrisJBurns merged 2 commits into
stacklok:mainfrom
bharathvemula:toolhive-7119-regression-tests

Conversation

@bharathvemula

Copy link
Copy Markdown
Contributor

Summary

#7119 reported that thv proxy stdio cannot initialize against the Semgrep remote MCP server: the bridge offered protocol version 2026-07-28 upstream, Semgrep 400s it (Unsupported protocol version: 2026-07-28), and initialize failed with no fallback. That was reported against CLI v0.53.0.

I reproduced the exact scenario on current main before changing anything, and the behavior is already fixed here: the go-sdk client (via toolhive-core v0.0.59) first probes with server/discover at 2026-07-28 and, when the server rejects it, falls back to a legacy initialize at 2025-11-25 — a version Semgrep supports — so the bridge completes initialize. The transparent proxy forwards both hops verbatim. This PR locks that negotiation in with regression tests, so it cannot silently regress:

  • TestBridge_InitializeFallsBackToLegacyVersion — bridge against a Semgrep-like fake backend (400s anything newer than 2025-11-25, Semgrep's exact error body): discover 2026-07-28 -> 400, legacy initialize 2025-11-25 -> 200, notifications/initialized -> 202.
  • TestBridge_InitializeFallsBackViaTransparentProxy — the same backend through the transparent proxy, the actual thv proxy stdio <remote-workload> path: the proxy must not upgrade the legacy initialize back to Modern or reject the discover probe.
  • TestBridge_InitializeFailsWhenServerCapsBelowFallbackVersion — documents the fallback's boundary: the SDK retries only once, at 2025-11-25, so a server capping below that still fails initialize. This also proves the first two tests are sensitive (they fail when the fallback version itself is rejected).

Fixes #7119

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe): Regression tests (no behavior change)

Test plan

  • Unit tests (task test equivalent — task is not installed on this machine, so the Taskfile equivalents were run directly)
    • go test ./pkg/transport/ -run 'TestBridge_Initialize' -v -count=1 — all 3 new tests pass
    • go test ./pkg/transport/... -race -count=1 — full package suite passes
    • golangci-lint run --allow-parallel-runners ./pkg/transport/ — 0 issues
    • gofmt / go vet clean

Does this introduce a user-facing change?

No — tests only; no behavior change.

Special notes for reviewers

Regression coverage for stacklok#7119: a Semgrep-like server that 400s protocol version 2026-07-28 must still complete initialize through the stdio bridge, via the legacy initialize at 2025-11-25, both directly and through the transparent proxy.

Signed-off-by: Bharath Vemula <[email protected]>
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.08%. Comparing base (e7570b0) to head (6727923).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7124   +/-   ##
=======================================
  Coverage   82.07%   82.08%           
=======================================
  Files         928      928           
  Lines       94127    94127           
=======================================
+ Hits        77258    77260    +2     
+ Misses      16864    16862    -2     
  Partials        5        5           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns
ChrisJBurns merged commit 352fe5a into stacklok:main Nov 25, 2026
42 checks passed
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.

thv proxy stdio: upstream initialize fails against Semgrep remote MCP (Unsupported protocol version 2026-07-28), no fallback

2 participants