jackwener/OpenCLI · error · ArgumentError
Invalid Jira issue key: ${key}
Error message
Invalid Jira issue key: ${key} What it means
ArgumentError from `requireIssueKey` in clis/jira/shared.js:104, raised when the issue key fails the pattern /^[A-Za-z][A-Za-z0-9_]+-\d+$/: a project key (letters/digits/underscore, starting with a letter), a hyphen, then a numeric id. The key is validated client-side and uppercased on success.
Source
Thrown at clis/jira/shared.js:104
if (selection?.mode === 'selected') {
return [...new Set([...selection.ids, ...extraFields.filter(Boolean)])].join(',');
}
const configured = Object.values(configuredFieldNames()).filter(Boolean);
return [...new Set([...DEFAULT_ISSUE_FIELDS, ...configured, ...extraFields.filter(Boolean)])].join(',');
}
export function issueSelectionIncludes(selection, field) {
return selection === null || selection?.mode === 'auto' || selection?.ids?.includes(field) === true;
}
export function parseJiraLimit(value, fallback = 20, max = 100) {
return parseLimit(value, fallback, max, 'jira limit');
}
export function requireIssueKey(value) {
const key = requireString(value, 'Jira issue key');
if (!/^[A-Za-z][A-Za-z0-9_]+-\d+$/.test(key)) {
throw new ArgumentError(`Invalid Jira issue key: ${key}`, 'Expected a key like PROJECT-123.');
}
return key.toUpperCase();
}
function displayUser(user) {
if (!user || typeof user !== 'object') return '';
return String(user.displayName ?? user.name ?? user.emailAddress ?? user.accountId ?? '');
}
function valueName(value) {
if (!value) return '';
if (typeof value === 'string') return value;
if (typeof value === 'object') return String(value.name ?? value.value ?? value.key ?? value.id ?? '');
return String(value);
}
function valueNames(values) {
return Array.isArray(values) ? values.map(valueName).filter(Boolean) : [];View on GitHub (pinned to 49907e53dc)
Solutions
- Use the canonical key form: PROJ-123 (letters/digits/underscore project code, hyphen, number).
- Extract the key from a URL: the segment after /browse/.
- Replace smart dashes: change – or — to a plain hyphen -.
- If you only have a numeric id, resolve it via the Jira API or use the id directly with the appropriate API resource.
Example fix
// before key: 'https://jira.example.com/browse/proj-1' // after key: 'PROJ-1' // extracted key; input is uppercased by requireIssueKey
Defensive patterns
Strategy: validation
Validate before calling
const ISSUE_KEY_RE = /^[A-Za-z][A-Za-z0-9_]+-\d+$/;
function toIssueKey(input) {
// Accept a URL and extract the key
const fromUrl = input.match(/\/browse\/([A-Za-z][A-Za-z0-9_]+-\d+)/);
const key = (fromUrl ? fromUrl[1] : input).replace(/[\u2010-\u2015\u2212]/g, '-').trim();
if (!ISSUE_KEY_RE.test(key)) throw new Error(`Expected a key like PROJECT-123, got: ${input}`);
return key.toUpperCase();
} Type guard
const isIssueKey = (v) => typeof v === 'string' && /^[A-Za-z][A-Za-z0-9_]+-\d+$/.test(v.trim());
Try / catch
import { ArgumentError } from '@jackwener/opencli/errors';
try {
await run(['jira', 'issue', key]);
} catch (e) {
if (e instanceof ArgumentError && e.message.startsWith('Invalid Jira issue key')) {
console.error('Use PROJECT-123 form, not a URL or bare numeric id.');
} else throw e;
} Prevention
- Normalize inputs: extract /browse/<KEY> from pasted URLs.
- Replace smart dashes with plain hyphens after copy-paste.
- Uppercase project keys before passing (validating anyway).
- Never pass internal numeric issue ids where a key is required.
When it happens
Trigger: Passing a bare number (12345), a URL (https://jira.example.com/browse/PROJ-1), a lowercase-but-valid key is fine but things like PROJ-1a, -PROJ-1, PROJ 1, PROJ–1 (en dash) all fail, or an empty value.
Common situations: Pasting the full issue URL or a Jira ticket title instead of the key; smart-quote/en-dash corruption from copy-paste; scripts passing internal numeric ids.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid Jira --fields selection
- Invalid Jira field id in --fields
- --${name} must be a positive integer, got ${JSON.stringify(r
- Jira --fields must be a comma-separated string or auto
- Jira --fields auto cannot be combined with other field ids
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c578793fa827e3f1.
Report an issue: GitHub.