Convert _meta on initialize to Meta (1.x). Refs #54 - #64
Merged
logiscapedev merged 1 commit intoJul 28, 2026
Merged
Conversation
`ClientRequest::createInitializeRequest()` passed the decoded `_meta` array straight into the `?Meta` parameter of `InitializeRequestParams`, so any `initialize` request carrying `_meta` died with a TypeError during validation, before the handshake could be answered. Every other request family already converted `_meta` through `extractMeta()`. Clients that attach trace context to the handshake (SEP-414; Claude's web client sends `traceparent` / `baggage` there) could not connect at all. Backported from the v2 line, where the same call site already uses `extractMeta()`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
peter-gribanov
force-pushed
the
fix/1.x-initialize-meta-typeerror
branch
from
July 27, 2026 13:04
3dfc9b0 to
2dc2ad5
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ClientRequest::createInitializeRequest()on the1.xline passes the decoded_metaarray straight into the?Metaparameter ofInitializeRequestParams, so aninitializerequest carrying_metaaborts with aTypeErrorduring validation. This converts it through the existingextractMeta()helper — the same fix that already exists onmain(v2) — and adds a regression test.Motivation
Refs #54. That issue was closed with "should be fixed in the latest release", but the fix only ever landed on
main: on1.x(up to and includingv1.7.4) line 192 is still_meta: $params['_meta'] ?? null, while every other request family —resources/read,resources/subscribe,tools/call, … — already goes throughextractMeta()/ an equivalentnew Meta()loop.Real-world impact:
initializeis allowed to carry_meta(SEP-414 trace context on any request), and Claude's web client now does — it attachestraceparent,baggageandx-cloud-trace-contextto the handshake:{"id":1,"jsonrpc":"2.0","method":"initialize","params":{ "_meta":{"traceparent":"00-0cb6548322595e40d670720bbba87ac4-c8a51f90c9021bec-01","baggage":"sentry-trace_id=…"}, "capabilities":{},"clientInfo":{"name":"Anthropic/ClaudeAI","version":"1.0.0"}, "protocolVersion":"2025-11-25"}}Which fails before the server can answer anything:
Since it happens on the handshake, the whole connection is unusable — such clients cannot talk to a
1.xserver at all. Note theTypeErroralso escapesStandardPhpAdapter::handle(), which catches\Exceptiononly, so the embedder sees a fatal rather than a JSON-RPC error.Type of change
Versioning impact
v1.7.X) — non-breaking bug fix or minor feature/improvementv1.X) — breaking change, major new feature, or expanded MCP protocol version supportv2) — aligned with a wider MCP ecosystemv2(not chosen unilaterally)Test plan
composer checkpasses locally — 840 tests / 3159 assertions, PHPStan cleancomposer conformancepasses locally (or documented baseline change included) — not run: no Node.js available in the environment I had. The change is confined to one params-construction call site inClientRequest, no baseline files touched; happy to have CI or a maintainer run the suite.tests/Types/ClientRequestInitializeMetaTest.php: array_metabecomesMetawith fields preserved (and the request stillvalidate()s), absent_metastaysnull, non-array_metais ignored instead of fatal. All three fail on1.xwithout the source change (the first two with exactly theTypeErrorabove).v1.7.1server; the fix itself is so far verified by the unit tests only.Compatibility
Documentation
README.mdif the public API or usage changed — n/a, no public API changeCHANGELOG.mdunder[Unreleased]docs/that this PR contradicts — nothing contradictedAGENTS.md/CLAUDE.mdif the contributor-facing guidance changed — n/aAdditional notes
The inline comment is adapted from the v2 call site; I dropped its reference to the modern-envelope probe path, which doesn't exist on
1.x.Two things you may want to decide separately:
1.x— anyone on the stable line still hits it.StandardPhpAdapter::handle()should catch\Throwablerather than\Exception, so a futureErrorin the parse path degrades into a JSON-RPC error response instead of a fatal. Not touched here to keep this PR to one logical change.🤖 Generated with Claude Code