jackwener/OpenCLI · error · ArgumentError
chatgpt project commands require a project id or /g/g-p-<id>
Error message
chatgpt project commands require a project id or /g/g-p-<id> URL
What it means
Fallback branch of parseChatGPTProjectId: when the value is not a URL/path and matches neither the g-p-<hex> slug pattern nor a bare 8+-char hex id, this ArgumentError is thrown.
Source
Thrown at clis/chatgpt/utils.js:980
`);
await page.wait(0.5);
}
export function parseChatGPTProjectId(value) {
const raw = String(value ?? '').trim();
if (/^https?:\/\//i.test(raw) || raw.startsWith('/')) {
const id = projectIdFromUrl(raw);
if (id) return id;
throw new ArgumentError(
'chatgpt project commands require a chatgpt.com project id or /g/g-p-<id> URL',
'Example: opencli chatgpt project-file-add report.pdf --id 12345678',
);
}
// Accept project slug pattern: g-p-{hex_id}-{slug} or just hex id
const slugMatch = raw.match(/^g-p-([a-f0-9]{8,})/i);
if (slugMatch) return slugMatch[1].toLowerCase();
if (/^[a-f0-9]{8,}$/i.test(raw)) return raw.toLowerCase();
throw new ArgumentError(
'chatgpt project commands require a project id or /g/g-p-<id> URL',
'Example: opencli chatgpt project-file-add report.pdf --id 12345678',
);
}
async function closeChatGPTSidebar(page) {
// Close sidebar if open (it can cover the chat composer)
await page.evaluate(`
(() => {
const labels = ${JSON.stringify(CLOSE_SIDEBAR_LABELS)};
const closeBtn = Array.from(document.querySelectorAll('button')).find(b => labels.includes(b.getAttribute('aria-label') || ''));
if (closeBtn) closeBtn.click();
})()
`);
}
/**
* Clear and fill the ChatGPT composer without submitting it.View on GitHub (pinned to 49907e53dc)
Solutions
- Use the hex project id (8+ hex characters) from the chatgpt.com project URL /g/g-p-<id>
- Use the full /g/g-p-<id> URL form if you prefer pasting a link
- Trim stray whitespace or punctuation from the value
- Open the project in chatgpt.com and copy the id from the address bar
Example fix
// before opencli chatgpt project-file-add report.pdf --id 'my-report' // after opencli chatgpt project-file-add report.pdf --id 'a1b2c3d4e5f6'
Defensive patterns
Strategy: validation
Validate before calling
function isValidProjectId(v) {
const s = String(v ?? '').trim();
return /^[a-f0-9]{8,}$/i.test(s) || /^g-p-[a-f0-9]{8,}/i.test(s);
}
if (!isValidProjectId(id)) throw new Error('--id must be 8+ hex chars or a g-p-<hex> slug'); Type guard
function isProjectId(v) {
return typeof v === 'string' && (/^g-p-[a-f0-9]{8,}/i.test(v.trim()) || /^[a-f0-9]{8,}$/i.test(v.trim()));
} Try / catch
try {
await client.chatgpt.projectFileAdd(file, { id: rawId });
} catch (err) {
if (err instanceof ArgumentError && /require a project id/.test(err.message)) {
console.error('Pass the hex id from the /g/g-p-<id> URL, e.g. --id a1b2c3d4e5f6');
} else throw err;
} Prevention
- Validate the id against /^[a-f0-9]{8,}$/ before calling project commands
- Never pass project display names or slugs without the g-p- prefix
- Store canonical hex project ids, not full ad-hoc strings
- Copy ids only from chatgpt.com project URLs
When it happens
Trigger: Passing arbitrary strings — a project name/slug without the g-p- prefix, a short hex id under 8 chars, a numeric-only id, or a value with whitespace/special characters — to chatgpt project commands.
Common situations: Assuming a human-readable project name works as an id; copying only the slug suffix ('my-report') instead of the hex id; typos in the hex id; using an id copied from a different ChatGPT entity (e.g. a GPT id).
Related errors
- Unknown ChatGPT model "${model}"
- Unknown ChatGPT tool "${tool}"
- chatgpt project commands require a chatgpt.com project id or
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ce5fbc677c1224ad.
Report an issue: GitHub.