{"record":{"id":"b4b1742144d35cc5","repo":"microsoft/monaco-editor","slug":"invalid-argument","errorCode":null,"errorMessage":"Invalid argument","messagePattern":"Invalid argument","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/build-monaco-editor-core-pkg.ts","lineNumber":31,"sourceCode":"\tconst monacoEditorPackageJson = require(monacoEditorPackageJsonPath) as {\n\t\tversion: string;\n\t\tvscodeRef: string;\n\t};\n\tlet version: string;\n\tlet ref: string;\n\n\tconst arg = process.argv[2];\n\tif (arg === 'stable') {\n\t\tversion = monacoEditorPackageJson.version;\n\t\tref = monacoEditorPackageJson.vscodeRef;\n\t} else if (arg === 'nightly') {\n\t\tversion = getNightlyVersion(\n\t\t\tmonacoEditorPackageJson.version,\n\t\t\tgetNightlyEnv().PRERELEASE_VERSION\n\t\t);\n\t\tref = getNightlyEnv().VSCODE_REF;\n\t} else {\n\t\tthrow new Error('Invalid argument');\n\t}\n\n\tawait prepareMonacoEditorCoreRelease(version, ref);\n\n\t// npm package is now in dependencies/vscode/out-monaco-editor-core, ready to be published\n}\n\nasync function prepareMonacoEditorCoreRelease(version: string, vscodeRef: string) {\n\tawait rm(dependenciesPath, { force: true, recursive: true });\n\n\tlet vscodeCommitId: string;\n\n\tawait group('Checkout vscode', async () => {\n\t\tconst result = await gitShallowClone(\n\t\t\tvscodePath,\n\t\t\t'https://github.com/microsoft/vscode.git',\n\t\t\tvscodeRef\n\t\t);","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/scripts/ci/build-monaco-editor-core-pkg.ts#L13-L49","documentation":"Thrown by the monaco-editor-core release CI script when its single CLI argument is neither 'stable' nor 'nightly'. The script reads process.argv[2] to decide whether to publish a stable build (using the version/vscodeRef from package.json) or a nightly build (computing a prerelease version and reading env vars). Any other value, including undefined from a missing argument, aborts the build. This is a hard guard to prevent publishing an unversioned or misconfigured package.","triggerScenarios":"Running `node scripts/ci/build-monaco-editor-core-pkg.ts` with no argument, with a typo like 'nigthly' or 'Stable' (case-sensitive), or with an extra/positional argument that shifts argv[2]. Also triggered by invoking the script through a wrapper that forgets to forward the release kind.","commonSituations":"Local developer running the release script manually to test it; a CI pipeline whose job matrix passes the channel via a variable that resolved to empty; refactoring the script and forgetting the argument; copy-pasting the npm script without the trailing `-- stable`/`-- nightly`.","solutions":["Invoke the script with exactly one of: `node scripts/ci/build-monaco-editor-core-pkg.ts stable` or `... nightly`.","If calling via npm/pnpm, append the channel after `--`: `npm run <script> -- stable`.","In CI, ensure the job sets the argument from a known enum (e.g. `${{ matrix.channel }}` where channel ∈ {stable, nightly}) and fails the job config early if empty.","Double-check spelling and casing — the comparison is strict equality against lowercase 'stable'/'nightly'."],"exampleFix":"// before\n$ node scripts/ci/build-monaco-editor-core-pkg.ts\n// after\n$ node scripts/ci/build-monaco-editor-core-pkg.ts stable","handlingStrategy":"validation","validationCode":"// validate argv before invoking the build\nconst arg = process.argv[2];\nif (arg !== 'stable' && arg !== 'nightly') {\n  console.error(`Usage: node scripts/ci/build-monaco-editor-core-pkg.ts <stable|nightly>`);\n  process.exit(2);\n}\n// only then run the script","typeGuard":"function isReleaseChannel(arg: string | undefined): arg is 'stable' | 'nightly' {\n  return arg === 'stable' || arg === 'nightly';\n}","tryCatchPattern":null,"preventionTips":["Wrap the script invocation in an npm script that takes a named channel and forwards it: `npm run release:core -- stable`.","In CI, validate the channel variable against an enum before the step that runs this script.","Document the exact CLI contract in the script header or repo README."],"tags":["ci","cli","build","release","argument-validation"],"backgroundTag":null,"analyzedSha":"ca1b42dc896b99db78e1c743256e8654e12cea2d","analyzedAt":"2026-08-13T02:00:51.380Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}