Skip to content

fix(cli): minimist should not turn strings into numbers - #39148

Merged
Dmitry Gozman (dgozman) merged 8 commits into
microsoft:mainfrom
Skn0tt:minimist-string-opts
Feb 6, 2026
Merged

Dmitry Gozman (dgozman) merged 8 commits into
microsoft:mainfrom
Skn0tt:minimist-string-opts

Conversation

@Skn0tt

Copy link
Copy Markdown
Contributor

Object.entries(commands).map(([name, command]) => [name, generateCommandHelp(command)])
),
stringOptions: [...stringOptions],
booleanOptions: [...booleanOptions],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this outputs a lot more booleanOptions than we currently have:

"stringOptions": [
    "browser",
    "config",
    "profile",
    "modifiers",
    "filename",
    "domain",
    "path",
    "body",
    "content-type",
    "remove-header"
  ],
  "booleanOptions": [
    "extension",
    "headed",
    "persistent",
    "submit",
    "clear",
    "full-page",
    "httpOnly",
    "secure",
    "skills",
    "static"
  ]

const argv = process.argv.slice(2);
const args: MinimistArgs = require('minimist')(argv, { boolean: booleanOptions });
for (const option of booleanOptions) {
const args: MinimistArgs = require('minimist')(argv, { boolean: [...help.booleanOptions, 'help', 'version'], string: [...help.stringOptions, '_'] });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this work with mousemove? IIRC, it has two number arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CI says no!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

const argv = process.argv.slice(2);
const args: MinimistArgs = require('minimist')(argv, { boolean: booleanOptions });
for (const option of booleanOptions) {
const args: MinimistArgs = require('minimist')(argv, { boolean: [...help.booleanOptions, 'help', 'version'], string: [...help.stringOptions, '_'] });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should still include booleanOptions and globalOptions that are cli-only, instead of relying upon them being listed in help.

Alternatively, we can expose those from help, but I'd prefer that to be a separate PR.

Comment thread tests/mcp/cli-parsing.spec.ts Outdated
const { error, exitCode } = await cli('type', 'foo', '--submit=bar');
expect(exitCode).toBe(1);
expect(error).toContain(`error: '--submit' option: expected boolean, received string`);
// boolean options are silently allowed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Why is that? I'd prefer this to throw.
  • I also noticed that type --submit foo does not work on ToT. I hope it works with this PR, let's add a test for that.

Comment thread tests/mcp/cli-core.spec.ts Outdated
expect(snapshot).toContain(`- textbox [ref=e2]`);

const { snapshot: fillSnapshot } = await cli('fill', 'e2', '42', '--submit');
expect(fillSnapshot).toBe(`- textbox [active] [ref=e2]: "42"`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The [active] part will fail on some webkit bots.

@github-actions

github-actions Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

4 failed
❌ [chrome] › mcp/cli-parsing.spec.ts:31 › wrong option type @mcp-macos-15
❌ [chromium] › mcp/core.spec.ts:158 › browser_resize @mcp-macos-15
❌ [chromium] › mcp/launch.spec.ts:21 › test reopen browser @mcp-macos-15
❌ [webkit] › mcp/cli-session.spec.ts:55 › persistent session shows in list after close @mcp-macos-15

4723 passed, 135 skipped


Merge workflow run.

@dgozman
Dmitry Gozman (dgozman) merged commit 3d41df9 into microsoft:main Feb 6, 2026
5 of 6 checks passed
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.

playwright-cli fill command fails when input value is numeric — throws "expected string, received number" error

2 participants