Skip to content

fix(mcp): preserve userDataDir from config file when CLI options don't override#40370

Open
Will-hxw wants to merge 3 commits intomicrosoft:mainfrom
Will-hxw:fix/1446-userdatadir-config
Open

fix(mcp): preserve userDataDir from config file when CLI options don't override#40370
Will-hxw wants to merge 3 commits intomicrosoft:mainfrom
Will-hxw:fix/1446-userdatadir-config

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

  • In mergeConfig(), add ?? protection for userDataDir so it falls back to the base config when CLI overrides are undefined

Why

Issue #1446: userDataDir in the config file is ignored because mergeConfig() spreads overrides.browser (containing userDataDir: undefined from CLI parsing) before applying the ?? fallback for individual fields.

The bug: browserName and isolated are already protected with ?? operators in mergeConfig(). userDataDir was missing this protection, so undefined from CLI options would overwrite the config file value.

Fix: userDataDir: overrides.browser?.userDataDir ?? base.browser?.userDataDir

Validation

  • Logic follows the same pattern as browserName and isolated in the same function
  • Fix is minimal (1 line)

Related Issues

…sages level param

Fixes: microsoft/playwright-mcp#1429

When using zod with zodToJSONSchema, .describe() must come before
.default() to ensure the description is properly attached to the schema
before the JSON schema is generated.
…t override

In mergeConfig(), browserName and isolated are protected with ??
operator to fall back to base config when overrides are undefined.
userDataDir was missing this protection, causing CLI options
(undefined when --user-data-dir is not passed) to overwrite
the config file value with undefined.

Fixes: microsoft/playwright-mcp#1446
Fixes: microsoft#340
@Will-hxw
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@pavelfeldman
Copy link
Copy Markdown
Member

stray change in console, no test for the fix, unclear spread cause (pick should be picking defined only)

Issue microsoft#1446: mergeConfig() spreads overrides.browser before applying ??
fallback for individual fields. browserName and isolated already had ??
protection but userDataDir was missing, causing config file userDataDir
to be overwritten by undefined from CLI parsing.

Add test to verify config file userDataDir is preserved when CLI options
don't provide a userDataDir value.

Fixes microsoft/playwright-mcp#1446
@Will-hxw
Copy link
Copy Markdown
Author

Thanks for the review. I've addressed your concerns:

  1. stray change in console - reverted console.ts change so PR only contains userDataDir fix
  2. no test for the fix - added test case for userDataDir config preservation
  3. unclear spread cause - fix follows same pattern as browserName/isolated in same function

PR now contains only userDataDir ?? protection (1 line) plus test. Please re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

userDataDir in config file is ignored, browser always launches with in-memory profile

2 participants