{"record":{"id":"3edc4da91f5ec0bf","repo":"jackwener/OpenCLI","slug":"id-not-a-valid-grok-conversation-url-got-input","errorCode":null,"errorMessage":"id not a valid Grok conversation URL (got \"${input}\"); expected https://grok.com/c/<id>","messagePattern":"id not a valid Grok conversation URL \\(got \"(.+?)\"\\); expected https://grok\\.com/c/<id>","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/grok/utils.js","lineNumber":52,"sourceCode":"export function parseGrokSessionId(input) {\n    const raw = String(input ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError('id', 'must be a non-empty session ID or grok.com chat URL');\n    }\n    let candidate = raw;\n    if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(raw)) {\n        let parsed;\n        try {\n            parsed = new URL(raw);\n        } catch {\n            throw new ArgumentError('id', `not a valid Grok URL (got \"${input}\")`);\n        }\n        const host = parsed.hostname.toLowerCase();\n        const pathMatch = parsed.pathname.match(\n            /^\\/c\\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\\/?$/i,\n        );\n        if (parsed.protocol !== 'https:' || (host !== 'grok.com' && !host.endsWith('.grok.com')) || !pathMatch) {\n            throw new ArgumentError(\n                'id',\n                `not a valid Grok conversation URL (got \"${input}\"); expected https://grok.com/c/<id>`,\n            );\n        }\n        candidate = pathMatch[1];\n    }\n    if (!GROK_SESSION_ID_RE.test(candidate)) {\n        throw new ArgumentError(\n            'id',\n            `not a valid Grok session ID (got \"${input}\"); expected a UUID like \"7c4197f2-10a1-4ebb-a84a-fea89f4f1d06\" or a full https://grok.com/c/<id> URL`,\n        );\n    }\n    return candidate.toLowerCase();\n}\n\nexport async function isOnGrok(page) {\n    const url = await page.evaluate('window.location.href').catch(() => '');\n    if (typeof url !== 'string' || !url) return false;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/utils.js#L34-L70","documentation":"parseGrokSessionId parses URL-shaped inputs and requires an https URL on the grok.com host (or a subdomain) whose path is exactly /c/<uuid>. If the URL parses but the protocol, host, or path do not match, it throws this ArgumentError telling you the expected shape https://grok.com/c/<id>.","triggerScenarios":"Passing http://grok.com/c/<uuid> (wrong protocol), a share URL like https://grok.com/share/c/<uuid> (wrong path), https://grok.com/chat/<uuid> (wrong path prefix), or a non-grok host like https://example.com/c/<uuid>.","commonSituations":"Users copy a conversation link from the Grok web app that uses a different route (/share/c/, /chat/) than the /c/ route the parser expects; bookmarking the http:// version of the site; using a competitor/mirror domain.","solutions":["Open the conversation on grok.com and copy the URL exactly in the form https://grok.com/c/<uuid>.","If you only have a share link, extract the UUID and pass the bare UUID as the id instead.","If passing a bare id, make sure it is the UUID itself so the URL branch is skipped.","Check the protocol is https, not http."],"exampleFix":"// before\nparseGrokSessionId('https://grok.com/share/c/7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')\n// after\nparseGrokSessionId('https://grok.com/c/7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')\n// or\nparseGrokSessionId('7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')","handlingStrategy":"validation","validationCode":"function isGrokConversationUrl(s) {\n  try {\n    const u = new URL(s);\n    return u.protocol === 'https:' &&\n      (u.hostname === 'grok.com' || u.hostname.endsWith('.grok.com')) &&\n      /^\\/c\\/[0-9a-f-]{36}\\/?$/i.test(u.pathname);\n  } catch { return false; }\n}","typeGuard":"function isGrokConversationUrl(input) {\n  if (typeof input !== 'string') return false;\n  try {\n    const u = new URL(input);\n    return u.protocol === 'https:' && u.hostname.endsWith('grok.com') && u.pathname.startsWith('/c/');\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  const sessionId = parseGrokSessionId(raw);\n} catch (e) {\n  if (/expected https:\\/\\/grok.com\\/c/.test(e.message)) {\n    // extract UUID from whatever link shape you have and retry\n    const m = raw.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);\n    if (m) return parseGrokSessionId(m[1]);\n  }\n  throw e;\n}","preventionTips":["Copy the URL directly from the grok.com /c/ page, not share or chat links","Ensure https not http","Extract and pass the UUID when the link shape is uncertain","Keep a small test that runs parseGrokSessionId on your stored ids"],"tags":["argument-validation","url-format","cli"],"backgroundTag":"invalid-url-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}