jackwener/OpenCLI · error · ArgumentError
--pick label cannot be empty
Error message
--pick label cannot be empty
What it means
findUniquePickerOption normalizes the --pick label (collapse whitespace, trim, lowercase) and throws ArgumentError immediately when the normalized label is empty, since there is nothing meaningful to match picker options against.
Source
Thrown at clis/codex/send.js:11
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError, selectorError } from '@jackwener/opencli/errors';
import { unwrapEvaluateResult } from './_actions.js';
import { conversationSelectionArgs, openCodexConversation } from './sidebar.js';
const PICKER_ITEM_SELECTOR = '[data-list-navigation-item="true"]';
export function findUniquePickerOption(options, rawLabel) {
const wanted = String(rawLabel ?? '').replace(/\s+/g, ' ').trim().toLowerCase();
if (!wanted) {
throw new ArgumentError('--pick label cannot be empty');
}
const normalized = options.map((option, index) => ({
index,
title: String(option.title ?? ''),
normalizedTitle: String(option.title ?? '').replace(/\s+/g, ' ').trim().toLowerCase(),
normalizedText: String(option.text ?? option.title ?? '').replace(/\s+/g, ' ').trim().toLowerCase(),
}));
const exact = normalized.filter(item => item.normalizedTitle === wanted);
if (exact.length === 1) {
return exact[0];
}
if (exact.length > 1) {
throw new CommandExecutionError(`Picker option "${rawLabel}" is ambiguous.`, `Matches: ${exact.map(item => item.title).join(', ')}`);
}
const partial = normalized.filter(item => item.normalizedText.includes(wanted));
if (partial.length === 1) {
return partial[0];
}View on GitHub (pinned to 49907e53dc)
Solutions
- Provide a non-empty --pick label matching (a part of) the picker option title.
- Validate/trim the pick value before calling and fall back to no --pick if empty.
- Check shell quoting and variable expansion so the label isn't dropped.
Example fix
// before
const pick = process.env.PICK; // undefined
codexSend({ pick }); // ArgumentError: --pick label cannot be empty
// after
const pick = (process.env.PICK || '').trim();
codexSend(pick ? { pick } : {}); Defensive patterns
Strategy: validation
Validate before calling
const pick = String(kwargs.pick ?? '').trim();
if (kwargs.pick != null && !pick) {
throw new Error('--pick given but empty; omit it or provide a label');
} Type guard
function isValidPickLabel(v) {
return v == null || (typeof v === 'string' && v.trim().length > 0);
} Try / catch
try {
await codexSend({ text, pick });
} catch (e) {
if (e instanceof ArgumentError && /--pick/.test(e.message)) {
console.error('Fix or drop the --pick flag.');
process.exitCode = 2;
return;
}
throw e;
} Prevention
- Omit --pick entirely when you have no label.
- Trim and check pick labels in wrapper scripts before passing.
- Guard shell interpolations: only add --pick when the variable is non-empty.
When it happens
Trigger: Calling sendCommand (which calls findUniquePickerOption) with rawLabel being null/undefined, an empty string, or a string of only whitespace such as '--pick " "'.
Common situations: Passing an unset shell variable as --pick "$PICK"; quoting mistakes that drop the value; programmatically passing kwargs.pick = '' ; whitespace-only label copied from UI text.
Related errors
- title cannot be empty
- title must be a single line
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] o
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/aabfb38effc2f44f.
Report an issue: GitHub.