Fix stdin message splitting for back-to-back newline-delimited messages#1758
Draft
garrytrinder with Copilot wants to merge 3 commits into
Draft
Fix stdin message splitting for back-to-back newline-delimited messages#1758garrytrinder with Copilot wants to merge 3 commits into
garrytrinder with Copilot wants to merge 3 commits into
Conversation
When multiple newline-delimited messages arrive in the same buffer read (e.g., a notification followed by a request), each message is now split and processed individually through the plugin pipeline. This ensures that @stdin.body.id placeholders resolve correctly for each message. Previously, the entire buffer was passed as a single Body to plugins, causing JSON parsing to fail or only parse the first message when multiple messages were concatenated. Closes #1757
Copilot
AI
changed the title
[WIP] Fix placeholder resolution in MockStdioResponsePlugin
Fix stdin message splitting for back-to-back newline-delimited messages
Jul 13, 2026
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.
MockStdioResponsePlugin's@stdin.body.idplaceholder fails to resolve when messages arrive in the samestdin.Readbuffer — e.g., a JSON-RPC notification (noid) immediately followed by a request (withid). The entire multi-message buffer was passed as a singleBodyto the plugin pipeline, so JSON parsing would fail or only see the first message.Changes
ForwardStdinAsyncnow accumulates data in aStringBuilder, splits on\n, and dispatches each complete line individually through the plugin pipeline.Decoderinstead of rawEncoding.UTF8.GetStringto avoid corrupting characters split across read boundaries.Before/After
Before: a single
stdin.Readreturning{...notification...}\n{...request...}\nproduced oneStdioRequestArgswith the concatenated content asBody.After: each newline-delimited message becomes its own
StdioRequestArgs, so placeholder resolution sees the correct JSON for each message independently.