fix (ai/mcp): prevent mutation of customEnv#5583
Merged
lgrammel merged 5 commits intovercel:mainfrom Apr 7, 2025
cgoinglove:fix-customenv-mutation
Merged
fix (ai/mcp): prevent mutation of customEnv#5583lgrammel merged 5 commits intovercel:mainfrom cgoinglove:fix-customenv-mutation
lgrammel merged 5 commits intovercel:mainfrom
cgoinglove:fix-customenv-mutation
Conversation
Collaborator
|
lgrammel
reviewed
Apr 7, 2025
lgrammel
reviewed
Apr 7, 2025
… is not mutated" This reverts commit 8c46fc0.
lgrammel
approved these changes
Apr 7, 2025
lgrammel
reviewed
Apr 7, 2025
lgrammel
pushed a commit
that referenced
this pull request
Apr 7, 2025
Contributor
Author
|
@lgrammel Thanks for your review! Let's gooo 🚀 |
samdenty
added a commit
that referenced
this pull request
Apr 7, 2025
* origin/v5: fix (ai/mcp): prevent mutation of customEnv (#5583)
lgrammel
reviewed
Apr 8, 2025
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.
Description
This PR fixes an issue where the original
customEnvobject passed to functions inget-environment.tswas being mutated due to JavaScript's pass-by-reference behavior for objects.Problem
When a configuration object with an
envproperty was passed tocreateChildProcess, any modifications to the environment inside the function would also affect the original object, potentially causing unexpected behavior in subsequent code.In our project, we encountered this issue specifically when using
serverConfigwith the MCP client:After the
createMCPClientcall, we discovered that the originalserverConfig.envwas being modified. This could cause problems when:This change preserves the immutability of configuration objects throughout the application, making the code more predictable and preventing hard-to-trace bugs that might occur when objects are unexpectedly modified.