{"record":{"id":"f2c9afbee6bf3371","repo":"ReactiveX/rxjs","slug":"option-requires-a-value","errorCode":null,"errorMessage":"${option} requires a value","messagePattern":"(.+?) requires a value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/migrate/src/cli.ts","lineNumber":178,"sourceCode":"    }\n  }\n  return options;\n}\n\nfunction validateArguments(options: CliOptions): asserts options is RunnableCliOptions {\n  const missing = [\n    options.files.length === 0 ? 'at least one source file' : undefined,\n    options.sourceRoot ? undefined : '--source-root',\n    options.repository ? undefined : '--source-repo',\n    options.sha ? undefined : '--source-sha',\n  ].filter((value): value is string => value !== undefined);\n  if (missing.length > 0) throw new Error(`Missing required argument${missing.length === 1 ? '' : 's'}: ${missing.join(', ')}`);\n  if (options.write && !options.outputRoot) throw new Error('--out-dir is required with --write');\n}\n\nfunction requiredValue(argv: readonly string[], index: number, option: string): string {\n  const value = argv[index];\n  if (!value || value.startsWith('-')) throw new Error(`${option} requires a value`);\n  return value;\n}\n\nfunction errorReport(code: MigrationCliErrorReport['error']['code'], message: string): MigrationCliErrorReport {\n  return { schemaVersion: migrationCliReportSchemaVersion, status: 'error', error: { code, message } };\n}\n\nfunction writeJson(stream: Pick<NodeJS.WriteStream, 'write'>, value: MigrationCliReport | MigrationCliErrorReport): void {\n  stream.write(`${JSON.stringify(value, null, 2)}\\n`);\n}\n\nfunction messageFor(error: unknown): string {\n  return error instanceof Error ? error.message : String(error);\n}\n\nfunction usage(): string {\n  return [\n    'Usage: rxjs-migrate [options] <test files...>',","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/migrate/src/cli.ts#L160-L196","documentation":"Thrown by the requiredValue helper when an option that expects a value is either the last token on the command line or is followed by another flag-like token. It guards --source-root, --source-repo, --source-sha, --mode, --framework, and --out-dir from silently consuming nothing.","triggerScenarios":"Ending the command with a value-taking flag (`... --source-sha`), or following it with another flag (`--mode --write`), or an empty shell variable (`--source-sha \"$SHA\"` when SHA is unset becomes a later failure or flag-adjacent token).","commonSituations":"Unset environment variables in CI scripts, truncated copy-pasted commands, or reordering flags and dropping the value.","solutions":["Supply a concrete value immediately after the option","Check that shell variables used for values are non-empty (`echo \"$SHA\"`)","Reorder the command so each value-taking flag is followed by its value"],"exampleFix":"# before\nSHA=\nnpx @rxjs/migrate --source-sha \"$SHA\" ...\n# after\nSHA=$(git rev-parse HEAD)\nnpx @rxjs/migrate --source-sha \"$SHA\" ...","handlingStrategy":"validation","validationCode":"const needsValue = new Set(['--source-root','--source-repo','--source-sha','--mode','--framework','--out-dir']);\nfor (let i = 0; i < argv.length; i++) {\n  if (needsValue.has(argv[i]) && (!argv[i+1] || argv[i+1].startsWith('-'))) {\n    throw new Error(`${argv[i]} is missing its value`);\n  }\n}","typeGuard":"const hasValue = (argv: string[], i: number) => Boolean(argv[i+1]) && !argv[i+1].startsWith('-');","tryCatchPattern":"try { runCli(argv); } catch (e) { console.error((e as Error).message); /* names the option lacking a value */ }","preventionTips":["Assert CI variables are non-empty before building the command","Prefer `--flag=value` ordering checks or build argv from a typed object"],"tags":["cli","argument-validation"],"backgroundTag":"missing-option-value","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}