Meta tags:
description= An AI Gateway, registry, and proxy that sits in front of any MCP, A2A, or REST/gRPC APIs, exposing a unified endpoint with centralized discovery, guardrails and management. Optimizes Agent & Tool calling, and supports plugins. - fix(transport): remove manual Content-Length headers causing compression errors by ja8zyjits · Pull Request #5663 · IBM/mcp-context-forge;
Headings (most frequently used words):
uh, oh, comment, content, length, compression, this, context, left, choose, reason, for, hiding, issues, pull, saved, searches, fix, transport, remove, manual, headers, causing, errors, navigation, to, mcp, forge, 5457, bug, mismatch, when, enabled, related, footer, loading, testing, gandhipratik203, search, code, repositories, users, requests, provide, feedback, 5663, request, menu, use, filter, your, results, more, quickly, 5663ja8zyjits, merged, commits, intomainibm, mainfrom, 2ibm, 2copy, head, branch, name, clipboard, conversation, issue, summary, reviewability, type, of, change, verification, checklist, notes, ja8zyjits, commented, jul, 16, 2026, edited, there, was, an, error, while, please, reload, page, automated, test, coverage, files, modified, known, limitation, review, follow, up, architecture, strategy, msureshkumar88, reviewers, assignees, labels, projects, milestone, development, participants,
Text of the page (most frequently used words):
the (56), #content (48), length (48), this (47), #compression (30), and (21), code (20), tests (20), 2026 (19), changes (17), comment (17), for (16), from (15), when (15), response (15), pull (14), manual (14), request (13), there (13), was (13), error (13), jul (13), with (13), fix (13), that (12), github (12), while (12), reload (12), ja8zyjits (12), middleware (12), applied (11), bug (11), review (11), view (11), all (11), validationmiddleware (11), bytes (11), headers (11), security (10), please (10), loading (10), enabled (10), pass (10), mcp (10), copy (10), transport (10), can (9), page (9), mismatch (9), issues (9), gandhipratik203 (9), 5457 (9), regression (9), mcpgateway (9), reason (9), ibm (9), errors (9), line (8), branch (8), unit (8), test (8), compressed (8), responses (8), you (7), not (7), suggestion (7), cannot (7), suggestions (7), merge (7), added (7), path (7), declared (7), quality (7), remove (7), context (7), change (6), single (6), requested (6), merged (6), main (6), worker (6), rpc (6), true (6), app (6), off (6), choose (6), hiding (6), signed (6), body (6), after (6), forge (6), your (6), enterprise (6), now (5), commit (5), invalid (5), these (5), brian (5), hussey (5), msureshkumar88 (5), sign (5), more (5), july (5), queue (5), into (5), checks (5), hide (5), blocking (5), real (5), pre (5), correctly (5), header (5), static (5), files (5), sets (5), skip (5), tools (5), issue (5), sanitization (5), causing (5), utf (5), session (5), set (5), transports (5), documentation (5), search (5), community (4), navigation (4), multi (4), resolved (4), outdated (4), add (4), one (4), lang (4), akshay (4), owner (4), crivetimihai (4), approved (4), characters (4), text (4), learn (4), via (4), details (4), reactions (4), sorry (4), something (4), went (4), wrong (4), redis (4), new (4), streamablehttp_transport (4), actual (4), http (4), requests (4), post (4), fixes (4), low (4), topic (4), describe (4), others (4), collaborator (4), markdown (4), link (4), but (4), commits (4), replacement (4), source (4), are (4), make (4), test_streamablehttp_compression_contentlength (4), support (4), status (3), check (3), has (3), must (3), lines (3), batch (3), only (3), closed (3), projects (3), awaiting (3), already (3), conversation (3), hidden (3), unicode (3), than (3), open (3), mentioned (3), without (3), e2e (3), full (3), green (3), failing (3), forwarded (3), stale (3), matches (3), two (3), loopback (3), fixed (3), same (3), analysis (3), gzip (3), against (3), wire (3), json (3), head (3), client (3), too (3), much (3), data (3), 500 (3), compression_enabled (3), duplicate (3), abuse (3), spam (3), will (3), displayed (3), problem (3), left (3), reviewed (3), updated (3), com (3), addressed (3), manually (3), before (3), uncompressed (3), locations (3), byte (3), bogdan (3), marius (3), catanus (3), still (3), routing (3), testing (3), layer (3), compressionmiddleware (3), test_validation_middleware_contentlength (3), coverage (3), name (3), 5663 (3), insights (3), actions (3), settings (3), another (3), tab (3), window (3), refresh (3), saved (3), use (3), feedback (3), grade (3), features (3), copilot (3), platform (3), solutions (3), explore (3), manage (2), footer (2), comments (2), existing (2), order (2), create (2), deleted (2), because (2), successfully (2), merging (2), may (2), development (2), milestone (2), none (2), yet (2), file (2), bidirectional (2), what (2), below (2), passed (2), tasks (2), other (2), work (2), removed (2), suite (2), live (2), run (2), repro (2), earlier (2), both (2), ran (2), including (2), encoding (2), 588 (2), httpx (2), h11 (2), read (2), through (2), reports (2), process (2), out (2), corruption (2), force (2), false (2), venv (2), bin (2), end (2), verification (2), results (2), look (2), focused (2), side (2), e5ed166 (2), jitesh (2), nair (2), jiteshnair (2), runs (2), size (2), prevent (2), future (2), 5461 (2), updates (2), validation_middleware (2), original (2), sizes (2), large (2), environment (2), forwarding (2), doesn (2), connection (2), tracked (2), related (2), verifies (2), final (2), helper (2), pytest (2), lint (2), type (2), they (2), clear (2), update (2), could (2), clipboard (2), discussions (2), appearance (2), cancel (2), see (2), available (2), searches (2), repositories (2), business (2), advanced (2), developer (2), topics (2), resources (2), customer (2), services (2), devops (2), perform, action, time, share, personal, information, cookies, contact, docs, privacy, terms, inc, right, back, later, queued, pending, reviews, been, marked, valid, applying, supported, per, viewing, subset, were, made, participants, close, labels, assignees, reviewers, have, account, join, free, show, contains, interpreted, compiled, differently, appears, editor, reveals, about, release, 5738, cafalchio, 77d99df, pyright, extensive, 5702, self, assigned, due, failed, bot, reaction, reacted, heart, emoji, given, passes, demonstrably, corrects, defects, approving, honest, caveat, sandbox, reach, cross, 4246, since, recalculates, its, own, regardless, specific, verified, above, rather, starlette, compress, points, round, updating, covered, copied, tree, them, fail, counts, finds, brotli, zstd, deflate, proof, comparing, parent, isolated, worktree, 098dc0ea1, decompressed, parsed, returned, protocol, result, behave, under, output, e5ed1668d, replayed, class, strict, remoteprotocolerror, http1, dispatch, called, internally, authenticated, raw, gunzip, parse, truncation, curl, accept, script, anyone, who, wants, rerun, live_gateway, e2e_content_length_compression, registered, rest, over, threshold, list, config, defaults, plugins_enabled, auth_required, compression_minimum_size, fresh, sqlite, jwt, auth, uvicorn, setup, independent, running, gateway, mocks, confirm, good, increments, get_value, locally, reran, instance, counter, findings, compare, 194f9e5, pushed, 2b78f02, setting, causes, streamablehttp, occurrences, compressing, ensuring, transmitted, count, d966120, causi, rewrites, sanitized, changing, leaving, 279, 290, produce, is_internally_forwarded, 4259, thanks, narrowing, down, remain, owners, different, algorithms, affinity, cycle, stack, recommended, deployment, integration, confirms, skips, verify, strategy, modify, compresses, generates, reverse, registration, asgi, execution, architecture, addresses, exists, where, sessions, cleaned, cascading, failures, initial, separately, documented, 5460, secondary, primary, asserts, remains, unset, expansion, compares, encoded, follow, unlikely, trigger, messages, typically, should, consistency, 503, mcp_ingress_mount, 195, priority, location, known, limitation, notes, secrets, credentials, committed, applicable, formatted, black, isort, checklist, 235, 394, recalculate, 4358, local, 4256, 4188, 1312, _send_streamable_http_json_response, core, modified, test_validation_middleware_case_insensitive_content_encoding, test_validation_middleware_handles_empty_content_encoding, test_validation_middleware_preserves_large_compressed_responses, test_validation_middleware_handles_missing_content_encoding, test_validation_middleware_updates_content_length_after_invalid_utf8_decode, test_validation_middleware_updates_content_length_only_if_modified, test_validation_middleware_sanitizes_uncompressed_responses, test_validation_middleware_skips_deflate_compressed_responses, test_validation_middleware_skips_zstd_compressed_responses, test_validation_middleware_skips_brotli_compressed_responses, test_validation_middleware_skips_gzip_compressed_responses, payloads, 10kb, test_large_response_with_compression, behavior, test_content_length_with_compression_disabled, test_redis_forwarded_response_no_content_length, test_loopback_rpc_routing_no_content_length, flow, test_compression_middleware_sets_content_length_correctly, function, test_send_json_response_no_content_length, total, debug, python, command, automated, chore, deps, tooling, refactor, feature, enhancement, assisted, understand, explain, generated, included, validate, unrelated, bugs, improvements, separate, prs, linked, labeled, triage, purpose, reviewability, eliminates, larger, active, which, production, usage, tool, calling, stage, impact, let, solution, default, streamable, based, then, sent, also, retain, expanded, during, root, cause, occurring, removing, summary, closes, alternative, commented, edited, changed, additional, options, 219, 849, star, fork, 758, notification, notifications, public, message, dismiss, alert, switched, accounts, resetting, focus, qualifiers, our, query, filter, quickly, submit, include, email, address, contacted, every, piece, take, input, very, seriously, provide, syntax, tips, users, jump, pricing, premium, ons, powered, collections, trending, archive, program, stars, accelerator, maintainer, lab, programs, fund, developers, sponsors, partners, trust, center, forum, skills, ebooks, events, webinars, stories, software, industries, government, manufacturing, financial, healthcare, industry, cases, devsecops, modernization, case, nonprofits, startups, small, medium, teams, enterprises, company, marketplace, changelog, blog, why, stop, leaks, start, secret, protection, secure, build, find, vulnerabilities, application, enforce, plan, track, instant, dev, environments, codespaces, automate, any, workflow, workflows, integrate, external, registry, direct, agents, write, better, creation, toggle, menu,
Text of the page (random words):
causing compression errors 5663 ja8zyjits merged 3 commits into main ibm mcp context forge main from 5457 bug content length mismatch when compression enabled 2 ibm mcp context forge 5457 bug content length mismatch when compression enabled 2 copy head branch name to clipboard conversation ja8zyjits commented jul 16 2026 edited loading uh oh there was an error while loading please reload this page copy link copy markdown collaborator alternative for 5461 pull request related issue closes 5457 summary fixes too much data for declared content length errors occurring when compression is enabled by removing manual content length headers that are set before the compression middleware runs root cause when compression_enabled true default the streamable http transport manually set content length based on uncompressed body sizes the compression middleware then compressed the response body but could not update the already sent headers validationmiddleware could also retain a stale content length after invalid utf 8 bytes expanded into replacement characters during sanitization solution remove manual content length headers from transport layer 4 locations in streamablehttp_transport py skip sanitization for compressed responses in validationmiddleware to prevent header corruption update content length when sanitization changes response bytes including invalid utf 8 replacement bytes let compression middleware set content length correctly after compression impact eliminates client side connection errors for responses larger than 500 bytes when compression is active which was blocking production usage of mcp tool calling in stage environment reviewability this pr has one clear purpose the linked issue is not labeled triage unrelated bugs or improvements are tracked in separate issues prs tests are included with the code they validate if ai assisted i understand and can explain the generated changes ️ type of change bug fix feature enhancement documentation refactor chore deps ci tooling other describe below verification automated testing check command status lint suite make lint pass unit tests make test pass regression tests uv run pytest tests unit mcpgateway transports test_streamablehttp_compression_contentlength py v 6 6 pass focused regression tests debug false venv bin python m pytest q tests unit mcpgateway middleware test_validation_middleware_contentlength py tests unit mcpgateway transports test_streamablehttp_compression_contentlength py 17 17 pass coverage 80 make coverage pass test coverage new regression tests added 17 total transport layer tests test_streamablehttp_compression_contentlength py test_send_json_response_no_content_length verifies helper function doesn t set content length test_compression_middleware_sets_content_length_correctly e2e flow with compression test_loopback_rpc_routing_no_content_length static analysis of source code test_redis_forwarded_response_no_content_length multi worker forwarding path test_content_length_with_compression_disabled behavior without compression test_large_response_with_compression large payloads 10kb validationmiddleware tests test_validation_middleware_contentlength py test_validation_middleware_skips_gzip_compressed_responses test_validation_middleware_skips_brotli_compressed_responses test_validation_middleware_skips_zstd_compressed_responses test_validation_middleware_skips_deflate_compressed_responses test_validation_middleware_sanitizes_uncompressed_responses test_validation_middleware_updates_content_length_only_if_modified test_validation_middleware_updates_content_length_after_invalid_utf8_decode test_validation_middleware_handles_missing_content_encoding test_validation_middleware_preserves_large_compressed_responses test_validation_middleware_handles_empty_content_encoding test_validation_middleware_case_insensitive_content_encoding files modified core fixes mcpgateway transports streamablehttp_transport py removed 4 manual content length locations line 1312 _send_streamable_http_json_response helper line 4188 loopback rpc routing line 4256 redis forwarded responses line 4358 local session owner routing mcpgateway middleware validation_middleware py skip compressed response sanitization and recalculate content length when final response bytes change test files added tests unit mcpgateway transports test_streamablehttp_compression_contentlength py 394 lines tests unit mcpgateway middleware test_validation_middleware_contentlength py 235 lines checklist code formatted make black isort pre commit tests added updated for changes documentation updated if applicable no secrets or credentials committed notes known limitation one low priority location still has manual content length mcpgateway transports mcp_ingress_mount py 195 503 error responses this is unlikely to trigger compression error messages typically 500 bytes but should be addressed for consistency in a future pr review follow up the validationmiddleware review comment is addressed content length now compares original response bytes with final encoded bytes invalid utf 8 regression test verifies replacement byte expansion updates an existing content length no change test now asserts that content length remains unset related issues this fix addresses the primary bug content length mismatch a secondary bug exists where mcp sessions are not cleaned up on connection errors causing cascading failures after the initial error this is tracked separately and documented in issue 5460 architecture context asgi middleware execution order response path is reverse of registration request validationmiddleware compressionmiddleware app response validationmiddleware compressionmiddleware app on the response path app generates uncompressed response compressionmiddleware compresses body and sets content length validationmiddleware must not modify compressed responses or headers testing strategy unit tests verify transport layer doesn t set content length manually compression middleware correctly sets content length after compression validationmiddleware skips compressed responses static analysis confirms no manual content length in source code integration testing recommended post deployment full request response cycle through middleware stack multi worker environment with redis forwarding session affinity routing with large responses different compression algorithms and response sizes sorry something went wrong uh oh there was an error while loading please reload this page all reactions ja8zyjits requested review from lang akshay brian hussey crivetimihai and msureshkumar88 as code owners july 16 2026 16 10 gandhipratik203 requested changes jul 16 2026 view reviewed changes gandhipratik203 left a comment copy link copy markdown collaborator there was a problem hiding this comment choose a reason for hiding this comment the reason will be displayed to describe this comment to others learn more choose a reason spam abuse off topic outdated duplicate resolved low quality hide comment thanks for narrowing this down two blocking issues remain streamablehttp_transport py 4259 still sets content length in the is_internally_forwarded rpc path with compression enabled this can still produce the original mismatch ci is already failing on the new static test validation_middleware py 279 290 rewrites response body after utf 8 replacement but only updates content length when the sanitized text changes invalid utf 8 can change byte length without changing that text leaving a stale header sorry something went wrong uh oh there was an error while loading please reload this page all reactions ja8zyjits mentioned this pull request jul 16 2026 fix transport remove manual content length headers causing compression errors 5461 closed 15 tasks bogdan marius catanus and others added 3 commits july 17 2026 11 28 fix transport middleware remove manual content length headers causi d966120 ng compression errors fixes 5457 when compression is enabled compression_enabled true manually setting content length headers before the compression middleware runs causes too much data for declared content length errors because the declared size is uncompressed but the actual body is compressed changes remove manual content length from streamablehttp transport 4 locations skip sanitization of compressed responses in validationmiddleware add 16 regression tests to prevent future occurrences the compression middleware now correctly sets content length after compressing the response body ensuring the header matches the actual transmitted byte count signed off by bogdan marius catanus bogdan marius catanus ibm com addressed the comments 2b78f02 signed off by jitesh nair jiteshnair ibm com fixed headers e5ed166 signed off by jitesh nair jiteshnair ibm com ja8zyjits force pushed the 5457 bug content length mismatch when compression enabled 2 branch from 194f9e5 to e5ed166 compare july 17 2026 11 17 ja8zyjits requested a review from gandhipratik203 july 17 2026 11 54 gandhipratik203 approved these changes jul 17 2026 view reviewed changes gandhipratik203 left a comment copy link copy markdown collaborator there was a problem hiding this comment choose a reason for hiding this comment the reason will be displayed to describe this comment to others learn more choose a reason spam abuse off topic outdated duplicate resolved low quality hide comment updated review no blocking findings from my side the earlier content length issues look fixed ci is green the focused regression tests pass locally 17 passed and i reran the single instance counter repro successfully increments 1 25 get_value 25 sorry something went wrong uh oh there was an error while loading please reload this page all reactions msureshkumar88 approved these changes jul 17 2026 view reviewed changes msureshkumar88 left a comment copy link copy markdown collaborator there was a problem hiding this comment choose a reason for hiding this comment the reason will be displayed to describe this comment to others learn more choose a reason spam abuse off topic outdated duplicate resolved low quality hide comment ran an independent end to end verification against a real running gateway not mocks to confirm this fixes 5457 and results look good setup venv bin uvicorn mcpgateway main app single process fresh sqlite db real jwt auth config compression_enabled true compression_minimum_size 500 defaults auth_required true plugins_enabled false registered 60 rest tools via post tools to force a tools list response over the compression threshold script tests live_gateway e2e_content_length_compression sh added in this branch for anyone who wants to rerun it what it checks against real http with accept encoding gzip post rpc authenticated json rpc raw wire bytes vs declared content length via curl d wc c gunzip json parse for truncation corruption post mcp with x forwarded internally true the same process loopback rpc dispatch path called out in the issue same checks both requests replayed through httpx client http1 true h11 the class of strict http 1 1 client that reports remoteprotocolerror too much data for declared content length output on this branch head e5ed1668d content encoding gzip declared content length 588 actual wire bytes 588 pass declared content length matches actual compressed wire bytes decompressed and parsed json ok tools returned 60 pass httpx h11 read the full response with no protocol error result pass compression content length behave correctly under real http regression proof comparing against the pre fix parent commit 098dc0ea1 in an isolated worktree copied this pr s two new regression test files into that pre fix tree and ran them there 9 of 17 fail including the static analysis check that counts manual content length header sets in streamablehttp_transport py finds 4 pre fix 0 on this branch and the validationmiddleware gzip brotli zstd deflate skip tests same test files on this branch 17 17 pass this matches the two blocking points from the earlier review round loopback rpc manual content length and validationmiddleware only updating length when text changes both now fixed and covered by tests one honest caveat my live e2e single worker no redis in my sandbox can t reach the redis forwarded cross worker path line 4246 since starlette compress recalculates content length correctly on its own in a single worker run regardless of the stale manual header so that specific path is verified via the unit static tests above rather than a live multi worker repro given real e2e passes full regression suite is green the fix demonstrably corrects the pre fix defects 9 failing 0 failing and ci is green approving sorry something went wrong uh oh there was an error while loading please reload this page ️ 1 ja8zyjits reacted with heart emoji all reactions ️ 1 reaction ja8zyjits added this pull request to the merge queue jul 17 2026 github merge queue bot removed this pull request from the merge queue due to failed status checks jul 17 2026 hide details view details uh oh there was an error while loading please reload this page gandhipratik203 self assigned this jul 20 2026 brian hussey mentioned this pull request jul 20 2026 bug pyright blocking merging without extensive other work 5702 closed 7 tasks ja8zyjits added this pull request to the merge queue jul 20 2026 hide details view details merged via the queue into main with commit 77d99df jul 20 2026 36 checks passed uh oh there was an error while loading please reload this page ja8zyjits deleted the 5457 bug content length mismatch when compression enabled 2 branch july 20 2026 10 08 cafalchio mentioned this pull request jul 21 2026 release v1 0 6 5738 merged this file contains hidden or bidirectional unicode text that may be interpreted or compiled differently than what appears below to review open the file in an editor that reveals hidden unicode characters learn more about bidirectional unicode characters show hidden characters sign up for free to join this conversation on github already have an account sign in to comment reviewers msureshkumar88 msureshkumar88 approved these changes gandhipratik203 gandhipratik203 approved these changes crivetimihai awaiting requested review from crivetimihai crivetimihai is a code owner brian hussey awaiting requested review from brian hussey brian hussey is a code owner lang akshay awaiting requested review from lang akshay lang akshay is a code owner assignees gandhipratik203 labels none yet projects none yet milestone no milestone development successfully merging this pull request may close these issues bug content length mismatch when compression enabled uh oh there was an error while loading please reload this page 3 participants add this suggestion to a batch that can be applied as a single commit this suggestion is invalid because no changes were made to the code suggestions cannot be applied while the pull request is closed suggestions cannot be applied while viewing a subset of changes only one suggest...
|