can1357/oh-my-pi · error
Invalid selection: ${choice}
Error message
Invalid selection: ${choice} What it means
After printing the numbered provider menu, `pickProviderInteractively` parses the user's line with `parseInt` and bounds-checks it against `1..providers.length`. Anything that is not a valid in-range integer throws this error instead of indexing out of bounds.
Source
Thrown at packages/coding-agent/src/cli/auth-broker-cli.ts:365
});
return promise;
}
async function pickProviderInteractively(providers: readonly OAuthProviderInfo[]): Promise<string> {
if (providers.length === 0) {
throw new Error("No OAuth providers registered");
}
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
try {
process.stdout.write("Select a provider:\n\n");
for (let i = 0; i < providers.length; i++) {
process.stdout.write(` ${i + 1}. ${providers[i].name}\n`);
}
process.stdout.write("\n");
const choice = await promptLine(rl, `Enter number (1-${providers.length}): `);
const index = Number.parseInt(choice, 10) - 1;
if (Number.isNaN(index) || index < 0 || index >= providers.length) {
throw new Error(`Invalid selection: ${choice}`);
}
return providers[index].id;
} finally {
rl.close();
}
}
async function runRemoteLogin(provider: string, via: string, dryRun: boolean): Promise<void> {
const port = CALLBACK_PORTS[provider];
if (port === undefined) {
throw new Error(
`No known OAuth callback port for '${provider}'. Use device-code flow on the broker host directly.`,
);
}
const sshArgs = [
"-L",
`${port}:127.0.0.1:${port}`,
"-o",View on GitHub (pinned to 9690622007)
Solutions
- Re-run the login and enter a number between 1 and the number of listed providers.
- Use `--provider=<id>` to bypass the interactive menu.
- When scripting, pipe exactly one valid number (e.g. `echo 2 | omp auth-broker login`).
Example fix
// before echo "" | omp auth-broker login // Invalid selection: // after omp auth-broker login --provider=github
Defensive patterns
Strategy: validation
Validate before calling
// feed only a valid menu index when scripting
const choice = 2;
if (!Number.isInteger(choice) || choice < 1 || choice > providerCount) {
throw new Error(`choose 1..${providerCount}`);
}
await prompt.write(String(choice) + "\n"); Try / catch
try {
await runLogin(flags);
} catch (err) {
if (err instanceof Error && err.message.startsWith("Invalid selection:")) {
console.error("Enter a number from the printed menu, or use --provider=<id>.");
} else throw err;
} Prevention
- Use `--provider=<id>` to bypass interactive menus entirely.
- Don't pipe arbitrary text into interactive prompts; send exactly one valid number.
- Answer with the number shown, not the provider name.
When it happens
Trigger: Answering the `Enter number (1-N)` prompt with an empty line, non-numeric text ('yes', 'q'), or a number outside the menu range; EOF/piped stdin producing an unparseable line.
Common situations: Interactive login with fat-fingered input; scripted runs piping arbitrary text into the prompt; pressing Enter expecting a default selection.
Related errors
- Import source is neither file nor directory: ${target}
- No files matched "${pattern}"
- Not a file: ${shortenPath(resolved)}
- --list-details, --exec, and --exec-batch are not supported b
- positional paths cannot be combined with --search-path
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/3167d9f9fb724734.
Report an issue: GitHub.