jackwener/OpenCLI · error · ArgumentError
chatgpt project commands require a chatgpt.com project id or
Error message
chatgpt project commands require a chatgpt.com project id or /g/g-p-<id> URL
What it means
parseChatGPTProjectId validates the --id argument for chatgpt project commands. When the value looks like a URL or path but no project id can be extracted from it (projectIdFromUrl returns nothing), it throws this ArgumentError with a usage example.
Source
Thrown at clis/chatgpt/utils.js:971
node.innerHTML = '<p><br></p>';
} else {
node.textContent = '';
}
node.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'deleteContentBackward', data: null }));
node.dispatchEvent(new Event('change', { bubbles: true }));
}
}
})()
`);
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(`
(() => {View on GitHub (pinned to 49907e53dc)
Solutions
- Copy the project URL directly from chatgpt.com — it must contain /g/g-p-<id>
- Pass just the bare hex project id (8+ hex chars) as --id instead of a URL
- Use the documented form: opencli chatgpt project-file-add report.pdf --id 12345678
- Check for typos/truncation in the pasted URL
Example fix
// before opencli chatgpt project-file-add report.pdf --id 'https://chatgpt.com/g/g-abc123' // after opencli chatgpt project-file-add report.pdf --id 'https://chatgpt.com/g/g-p-12345678abcdef'
Defensive patterns
Strategy: validation
Validate before calling
function looksLikeProjectRef(v) {
const s = String(v ?? '').trim();
if (/^https?:\/\/chatgpt\.com\/.+\/g\/g-p-[a-f0-9]{8,}/i.test(s)) return true;
return /^g\/g-p-[a-f0-9]{8,}/i.test(s);
}
if (!looksLikeProjectRef(id)) throw new Error('Provide a chatgpt.com /g/g-p-<id> URL or bare hex project id'); Try / catch
try {
await client.chatgpt.projectFileAdd(file, { id: rawId });
} catch (err) {
if (err instanceof ArgumentError && /project id or \/g\/g-p-/.test(err.message)) {
console.error('Bad --id. Example: opencli chatgpt project-file-add report.pdf --id 12345678');
} else throw err;
} Prevention
- Copy the project URL straight from the chatgpt.com address bar
- Confirm the URL contains /g/g-p- before passing it as --id
- Prefer passing the bare hex id extracted from the URL
- Don't confuse conversation (/c/), GPT (/g/g-), and project (/g/g-p-) URL formats
When it happens
Trigger: Passing a non-chatgpt.com URL, a chatgpt.com URL without the /g/g-p-<id> project path segment, a truncated or malformed project link, or a path like /g/g-<non-project-id> to project commands such as project-file-add with --id.
Common situations: Copy-pasting a regular conversation link instead of a project link; editing a URL by hand and dropping the g-p- segment; using an old-style project URL format that projectIdFromUrl no longer recognizes.
Related errors
- '${rawInput}' does not look like an autohome series id (a nu
- bilibili follow target must be a valid space.bilibili.com/<u
- Unknown ChatGPT model "${model}"
- Unknown ChatGPT tool "${tool}"
- chatgpt project commands require a project id or /g/g-p-<id>
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/374a92370004aca6.
Report an issue: GitHub.