{"record":{"id":"a909174ac75d14b7","repo":"jackwener/OpenCLI","slug":"chatgpt-detail-requires-a-conversation-id-or-chatg","errorCode":null,"errorMessage":"chatgpt detail requires a conversation id or chatgpt.com /c/<id> URL","messagePattern":"chatgpt detail requires a conversation id or chatgpt\\.com /c/<id> URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/utils.js","lineNumber":260,"sourceCode":"    } catch {\n        return '';\n    }\n}\n\nexport function parseChatGPTConversationId(value) {\n    const raw = String(value ?? '').trim();\n    if (/^https?:\\/\\//i.test(raw)) {\n        try {\n            const parsed = new URL(raw);\n            if (parsed.protocol !== 'https:' || (parsed.hostname !== CHATGPT_DOMAIN && !parsed.hostname.endsWith(`.${CHATGPT_DOMAIN}`))) {\n                throw new Error('off-domain');\n            }\n            const match = parsed.pathname.match(/^\\/(?:g\\/g-p-[^/]+\\/)?c\\/([A-Za-z0-9_-]{8,})$/);\n            if (match) return match[1];\n        } catch {\n            // Fall through to the shared typed ArgumentError below.\n        }\n        throw new ArgumentError(\n            'chatgpt detail requires a conversation id or chatgpt.com /c/<id> URL',\n            'Example: opencli chatgpt detail https://chatgpt.com/c/123e4567-e89b-12d3-a456-426614174000',\n        );\n    }\n    const pathMatch = raw.match(/^\\/(?:g\\/g-p-[^/]+\\/)?c\\/([A-Za-z0-9_-]{8,})(?:[?#].*)?$/);\n    if (pathMatch) return pathMatch[1];\n    if (/^[A-Za-z0-9_-]{8,}$/.test(raw)) return raw;\n    throw new ArgumentError(\n        'chatgpt detail requires a conversation id or chatgpt.com /c/<id> URL',\n        'Example: opencli chatgpt detail 123e4567-e89b-12d3-a456-426614174000',\n    );\n}\n\nexport async function currentChatGPTUrl(page) {\n    const url = unwrapEvaluateResult(await page.evaluate('window.location.href').catch(() => ''));\n    return typeof url === 'string' ? url : '';\n}\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/utils.js#L242-L278","documentation":"parseChatGPTConversationId accepts a raw conversation id or a chatgpt.com /c/<id> URL (including /g/g-p-.../c/<id> workspace forms). When given something URL-like that cannot be parsed into such a path, it throws this ArgumentError with an example URL hint.","triggerScenarios":"Passing a URL that is not a conversation URL: the share page /s/<id>, a chatgpt.com root/project URL, a foreign-domain URL, or a /c/ URL whose id is shorter than 8 chars.","commonSituations":"Copying a shared-chat link instead of the conversation URL, copying from the browser while on the home page, or passing an internal g/g-p project root link.","solutions":["Open the conversation in the browser and copy the URL matching chatgpt.com/c/<id>","Or pass just the raw conversation id (>= 8 chars of [A-Za-z0-9_-])","For shared links, open the share and copy the canonical /c/ conversation URL","Check the regex requirements: path must match /c/<id> with id length >= 8"],"exampleFix":"// before\nopencli chatgpt detail https://chatgpt.com/share/abc123\n// after\nopencli chatgpt detail https://chatgpt.com/c/123e4567-e89b-12d3-a456-426614174000","handlingStrategy":"validation","validationCode":"const m = String(input).match(/^https?:\\/\\/[^/]*chatgpt\\.com\\/(?:g\\/g-p-[^/]+\\/)?c\\/([A-Za-z0-9_-]{8,})/);\nif (!m && !/^[A-Za-z0-9_-]{8,}$/.test(input)) throw new Error('need a chatgpt.com /c/<id> URL or a raw conversation id');","typeGuard":"function isConversationRef(s) { return typeof s === 'string' && (/^[A-Za-z0-9_-]{8,}$/.test(s) || /chatgpt\\.com\\/(?:g\\/g-p-[^/]+\\/)?c\\/[A-Za-z0-9_-]{8,}/.test(s)); }","tryCatchPattern":"try { id = parseChatGPTConversationId(input); } catch (e) { if (e instanceof ArgumentError) { console.error(e.hint); } else throw e; }","preventionTips":["Copy the URL while the conversation is open, not a share link","Prefer passing the raw conversation id","Check the URL contains /c/ before invoking","Beware /s/ share URLs — they do not parse"],"tags":["argument-validation","url-parsing","conversation-id"],"backgroundTag":"invalid-conversation-id","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}