-
Notifications
You must be signed in to change notification settings - Fork 85
chore: use zod for arg-parser MCP-298 #2589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
.gitignore
Outdated
| snapshot.blob | ||
| .logs/* | ||
| !.logs/empty.xml | ||
| mongosh.code-workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a sneak-peak into a workspace configuration I managed to do which should let Mocha Test Runner extension plug into the mongosh test setup and let us run tests in VSCode debugging UI... pending some extra config 😄
This is preparation for its usage of MCP and further changes in #2589
| "semver": "^7.5.4", | ||
| "strip-ansi": "^6.0.0", | ||
| "text-table": "^0.2.0", | ||
| "glibc-version": "^1.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should remain here, no?
package-lock.json
Outdated
| "node": ">=14.15.1" | ||
| } | ||
| }, | ||
| "packages/arg-parser/node_modules/zod": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure we can use a single, hoisted copy of zod at the top level: #2598
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, didn't realize this was deviating from it; yeah! but would actually be better to stick to ^3.25.76 since that's what the MCP protocol SDK supports at them moment
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
addaleax
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
| /** | ||
| * CLI options schema with metadata attached via registry | ||
| */ | ||
| export const CliOptionsSchema = z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up, there'll be a small conflict with #2584
| gssapiServiceName: z.string().optional(), | ||
| sspiHostnameCanonicalization: z.string().optional(), | ||
| sspiRealmOverride: z.string().optional(), | ||
| jsContext: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mark other enums as such, this one should probably be handled similarly
| }), | ||
| sslDisabledProtocols: z.string().optional().register(cliOptionsRegistry, { | ||
| deprecationReplacement: 'tlsDisabledProtocols', | ||
| }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't we typically want to list the non-deprecated versions here and then mention the deprecated aliases in deprecationReplacement? Feels a bit backwards to have the deprecated versions at the top level
| oidcDumpTokens: z | ||
| .union([z.boolean(), z.enum(['redacted', 'include-secrets'])]) | ||
| .optional(), | ||
| browser: z.union([z.boolean(), z.string()]).optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw we wouldn't want to accept true as a boolean, i.e. --browser=true should be interpreted as literally referring to the true UNIX command line utility – false is the only special value that's supposed to be interpreted as not attempting to spawn an executable at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we'd expect --browser to be the only way this ends up being true? and in all other cases parse it as string?
by the way we do this which I assume doesn't mean much in this case:
| '--browser=false', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay, so false is valid but not true? Is this unique to brower or all others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay, so false is valid but not true? Is this unique to
broweror all others?
Yes :)
So something like:
--browser foo↦{ browser: "foo" }--browser=foo↦{ browser: "foo" }--browser↦ invalid, maybe error out--browser=true↦{ browser: "true" }--browser=false↦{ browser: false }--no-browser↦{ browser: false }
| "glibc-version": "^1.0.0", | ||
| "text-table": "^0.2.0" | ||
| "text-table": "^0.2.0", | ||
| "glibc-version": "^1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already in optionalDependencies (correctly so)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I swear npm is playing mind tricks to me I keep feeling like glic-version moves without me doing anything 😄 probably all my rebasing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you running .evergreen/install-npm-deps.sh by any chance? That's the only thing that I could think of that would make this happen (we mark "optional" dependencies as required there because in CI we do always want them)
A couple things here (though the state has changed)
--browser=truehave not been parsed correctly until now (concerning?) and the only real options have been the string-based ones. So this adds a) tests relating to this (which fail without the coercion change) and b) conditional coercing to boolean value when it istrueorfalse. This seems to be intended behavior but let me know if I'm overlooking it.