{"record":{"id":"374a92370004aca6","repo":"jackwener/OpenCLI","slug":"chatgpt-project-commands-require-a-chatgpt-com-pro","errorCode":null,"errorMessage":"chatgpt project commands require a chatgpt.com project id or /g/g-p-<id> URL","messagePattern":"chatgpt project commands require a chatgpt\\.com project id or /g/g-p-<id> URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/utils.js","lineNumber":971,"sourceCode":"                        node.innerHTML = '<p><br></p>';\n                    } else {\n                        node.textContent = '';\n                    }\n                    node.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'deleteContentBackward', data: null }));\n                    node.dispatchEvent(new Event('change', { bubbles: true }));\n                }\n            }\n        })()\n    `);\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        (() => {","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/utils.js#L953-L989","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nopencli chatgpt project-file-add report.pdf --id 'https://chatgpt.com/g/g-abc123'\n// after\nopencli chatgpt project-file-add report.pdf --id 'https://chatgpt.com/g/g-p-12345678abcdef'","handlingStrategy":"validation","validationCode":"function looksLikeProjectRef(v) {\n  const s = String(v ?? '').trim();\n  if (/^https?:\\/\\/chatgpt\\.com\\/.+\\/g\\/g-p-[a-f0-9]{8,}/i.test(s)) return true;\n  return /^g\\/g-p-[a-f0-9]{8,}/i.test(s);\n}\nif (!looksLikeProjectRef(id)) throw new Error('Provide a chatgpt.com /g/g-p-<id> URL or bare hex project id');","typeGuard":null,"tryCatchPattern":"try {\n  await client.chatgpt.projectFileAdd(file, { id: rawId });\n} catch (err) {\n  if (err instanceof ArgumentError && /project id or \\/g\\/g-p-/.test(err.message)) {\n    console.error('Bad --id. Example: opencli chatgpt project-file-add report.pdf --id 12345678');\n  } else throw err;\n}","preventionTips":["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"],"tags":["validation","argument-error","chatgpt","url-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}