{"record":{"id":"ce5fbc677c1224ad","repo":"jackwener/OpenCLI","slug":"chatgpt-project-commands-require-a-project-id-or","errorCode":null,"errorMessage":"chatgpt project commands require a project id or /g/g-p-<id> URL","messagePattern":"chatgpt project commands require a project id or /g/g-p-<id> URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/utils.js","lineNumber":980,"sourceCode":"    `);\n    await page.wait(0.5);\n}\n\nexport function parseChatGPTProjectId(value) {\n    const raw = String(value ?? '').trim();\n    if (/^https?:\\/\\//i.test(raw) || raw.startsWith('/')) {\n        const id = projectIdFromUrl(raw);\n        if (id) return id;\n        throw new ArgumentError(\n            'chatgpt project commands require a chatgpt.com project id or /g/g-p-<id> URL',\n            'Example: opencli chatgpt project-file-add report.pdf --id 12345678',\n        );\n    }\n    // Accept project slug pattern: g-p-{hex_id}-{slug} or just hex id\n    const slugMatch = raw.match(/^g-p-([a-f0-9]{8,})/i);\n    if (slugMatch) return slugMatch[1].toLowerCase();\n    if (/^[a-f0-9]{8,}$/i.test(raw)) return raw.toLowerCase();\n    throw new ArgumentError(\n        'chatgpt project commands require a project id or /g/g-p-<id> URL',\n        'Example: opencli chatgpt project-file-add report.pdf --id 12345678',\n    );\n}\n\nasync function closeChatGPTSidebar(page) {\n    // Close sidebar if open (it can cover the chat composer)\n    await page.evaluate(`\n        (() => {\n            const labels = ${JSON.stringify(CLOSE_SIDEBAR_LABELS)};\n            const closeBtn = Array.from(document.querySelectorAll('button')).find(b => labels.includes(b.getAttribute('aria-label') || ''));\n            if (closeBtn) closeBtn.click();\n        })()\n    `);\n}\n\n/**\n * Clear and fill the ChatGPT composer without submitting it.","sourceCodeStart":962,"sourceCodeEnd":998,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/utils.js#L962-L998","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\nopencli chatgpt project-file-add report.pdf --id 'my-report'\n// after\nopencli chatgpt project-file-add report.pdf --id 'a1b2c3d4e5f6'","handlingStrategy":"validation","validationCode":"function isValidProjectId(v) {\n  const s = String(v ?? '').trim();\n  return /^[a-f0-9]{8,}$/i.test(s) || /^g-p-[a-f0-9]{8,}/i.test(s);\n}\nif (!isValidProjectId(id)) throw new Error('--id must be 8+ hex chars or a g-p-<hex> slug');","typeGuard":"function isProjectId(v) {\n  return typeof v === 'string' && (/^g-p-[a-f0-9]{8,}/i.test(v.trim()) || /^[a-f0-9]{8,}$/i.test(v.trim()));\n}","tryCatchPattern":"try {\n  await client.chatgpt.projectFileAdd(file, { id: rawId });\n} catch (err) {\n  if (err instanceof ArgumentError && /require a project id/.test(err.message)) {\n    console.error('Pass the hex id from the /g/g-p-<id> URL, e.g. --id a1b2c3d4e5f6');\n  } else throw err;\n}","preventionTips":["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"],"tags":["validation","argument-error","chatgpt","identifier"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}