Skip to content

fix: keep rmcp-client env vars as OsString#15363

Merged
bolinfest merged 1 commit intomainfrom
pr15363
Mar 24, 2026
Merged

fix: keep rmcp-client env vars as OsString#15363
bolinfest merged 1 commit intomainfrom
pr15363

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Mar 21, 2026

Why

This is a follow-up to #15360. That change fixed the arg0 helper setup, but rmcp-client still coerced stdio transport environment values into UTF-8 Strings before program resolution and process spawn. If PATH or another inherited environment value contains non-UTF-8 bytes, that loses fidelity before it reaches which and Command.

What changed

  • change create_env_for_mcp_server() to return HashMap<OsString, OsString> and read inherited values with std::env::var_os()
  • change TransportRecipe::Stdio.env, RmcpClient::new_stdio_client(), and program_resolver::resolve() to keep stdio transport env values in OsString form within rmcp-client
  • keep the codex-core config boundary stringly, but convert configured stdio env values to OsString once when constructing the transport
  • update the rmcp-client stdio test fixtures and callers to use OsString env maps
  • add a Unix regression test that verifies create_env_for_mcp_server() preserves a non-UTF-8 PATH

How to verify

  • cargo test -p codex-rmcp-client
  • cargo test -p codex-core mcp_connection_manager
  • just argument-comment-lint

Targeted coverage in this change includes utils::tests::create_env_preserves_path_when_it_is_not_utf8, while the updated stdio transport path is exercised by the existing rmcp-client tests that construct RmcpClient::new_stdio_client().

@bolinfest bolinfest changed the base branch from main to pr15360 March 21, 2026 00:31
@bolinfest bolinfest changed the title fix: make more PATH reads OsString-aware fix: make remaining PATH reads OsString-aware Mar 21, 2026
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01e0584979

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +67
let new_path = env::join_paths(
std::iter::once(prefix.as_os_str()).chain(parts.iter().map(|path| path.as_os_str())),
)
.map_err(|err| anyhow!("failed to construct PATH: {err}"))?;
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.

P2 Badge Handle quoted PATH entries when prepending denybin

env::join_paths makes this PATH rewrite fallible on Windows: Rust returns Err if any existing PATH component contains a double quote. That matters here because apply_no_network_to_env() is called from run_windows_sandbox_capture(), so a machine with a quoted PATH entry (for example, some installers add quoted Program Files paths) will now fail the entire no-network sandbox launch before the command starts. The previous string concatenation preserved the user's PATH verbatim instead of aborting.

Useful? React with 👍 / 👎.

Base automatically changed from pr15360 to main March 24, 2026 01:59
@bolinfest bolinfest force-pushed the pr15363 branch 3 times, most recently from 6f8bf17 to 72fd48e Compare March 24, 2026 20:13
@bolinfest bolinfest changed the title fix: make remaining PATH reads OsString-aware fix: keep rmcp-client env vars as OsString Mar 24, 2026
@bolinfest bolinfest force-pushed the pr15363 branch 3 times, most recently from 14afae1 to f1c4ba1 Compare March 24, 2026 21:24
@bolinfest bolinfest enabled auto-merge (squash) March 24, 2026 22:30
@bolinfest bolinfest merged commit 4a210fa into main Mar 24, 2026
87 of 92 checks passed
@bolinfest bolinfest deleted the pr15363 branch March 24, 2026 23:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants