{"record":{"id":"85b4b7a2ae0671f0","repo":"microsoft/monaco-editor","slug":"invalid-argument-85b4b7","errorCode":null,"errorMessage":"Invalid argument","messagePattern":"Invalid argument","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/build-monaco-editor-pkg.ts","lineNumber":32,"sourceCode":");\n\nasync function prepareMonacoEditorReleaseStableOrNightly() {\n\tconst monacoEditorPackageJson = JSON.parse(\n\t\tawait readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })\n\t) as PackageJson;\n\n\tlet version: string;\n\n\tconst arg = process.argv[2];\n\tif (arg === 'stable') {\n\t\tversion = monacoEditorPackageJson.version;\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} else {\n\t\tthrow new Error('Invalid argument');\n\t}\n\n\tawait prepareMonacoEditorRelease(version);\n\n\t// npm package is now in ./out/monaco-editor, ready to be published\n}\n\nasync function prepareMonacoEditorRelease(monacoEditorCoreVersion: string) {\n\tawait group('npm ci', async () => {\n\t\tawait run('npm ci', { cwd: resolve(rootPath, 'webpack-plugin') });\n\t});\n\n\tawait group('Set Version & Update monaco-editor-core Version', async () => {\n\t\tconst packageJson = JSON.parse(await readFile(monacoEditorPackageJsonPath, { encoding: 'utf-8' })) as PackageJson;\n\t\tpackageJson.version = monacoEditorCoreVersion;\n\t\tpackageJson.devDependencies['monaco-editor-core'] = monacoEditorCoreVersion;\n\t\tawait writeJsonFile(monacoEditorPackageJsonPath, packageJson);\n\t});","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/scripts/ci/build-monaco-editor-pkg.ts#L14-L50","documentation":"Thrown by the monaco-editor (wrapper) release CI script when its CLI argument is neither 'stable' nor 'nightly'. Identical guard to the core script but for the consumer-facing monaco-editor package: 'stable' uses package.json's version directly, 'nightly' computes a prerelease version via getNightlyVersion and reads PRERELEASE_VERSION from env. Any other argv[2] value aborts before modifying package.json or running the build/test/package/smoketest pipeline.","triggerScenarios":"Running `node scripts/ci/build-monaco-editor-pkg.ts` without an argument or with a value other than 'stable'/'nightly'; a CI workflow that conditionally sets the channel and the condition evaluated to undefined; invoking through a runner that drops positional args.","commonSituations":"Developer testing the packaging flow locally; CI matrix variable not propagated; typo in the channel name; refactoring npm scripts and losing the `-- stable`/`-- nightly` suffix.","solutions":["Run with exactly one positional argument: `node scripts/ci/build-monaco-editor-pkg.ts stable` or `... nightly`.","When using npm run, pass the channel after `--`: `npm run build-monaco-editor-pkg -- nightly`.","In CI, validate the channel variable is non-empty and one of the two allowed values before invoking the script.","Check for casing/whitespace — the check is strict equality on lowercase strings."],"exampleFix":"// before\n$ node scripts/ci/build-monaco-editor-pkg.ts\n// after\n$ node scripts/ci/build-monaco-editor-pkg.ts nightly","handlingStrategy":"validation","validationCode":"const arg = process.argv[2];\nif (arg !== 'stable' && arg !== 'nightly') {\n  console.error('Usage: node scripts/ci/build-monaco-editor-pkg.ts <stable|nightly>');\n  process.exit(2);\n}\n// proceed","typeGuard":"function isReleaseChannel(arg: string | undefined): arg is 'stable' | 'nightly' {\n  return arg === 'stable' || arg === 'nightly';\n}","tryCatchPattern":null,"preventionTips":["Define npm scripts (e.g. `release:stable`, `release:nightly`) that pass the channel for you, removing the chance of a missing arg.","In CI, fail the job config early if the channel variable is empty rather than letting the script throw.","Keep the two release scripts' argv contracts identical so tooling can target either."],"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"}