{"record":{"id":"4de0934db81911dd","repo":"jackwener/OpenCLI","slug":"id-not-a-valid-grok-session-id-got-input-e","errorCode":null,"errorMessage":"id 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","messagePattern":"id not a valid Grok session ID \\(got \"(.+?)\"\\); expected a UUID like \"7c4197f2-10a1-4ebb-a84a-fea89f4f1d06\" or a full https://grok\\.com/c/<id> URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/grok/utils.js","lineNumber":60,"sourceCode":"        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;\n    try {\n        const hostname = new URL(url).hostname;\n        return hostname === 'grok.com' || hostname.endsWith('.grok.com');\n    } catch {\n        return false;\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/utils.js#L42-L78","documentation":"After URL normalization (or if the input was not URL-shaped at all), parseGrokSessionId validates the candidate against GROK_SESSION_ID_RE, which requires a lowercase-hex UUID. If neither a valid UUID nor a valid grok.com /c/<uuid> URL was supplied, this ArgumentError is thrown with an example UUID to guide you.","triggerScenarios":"Passing a non-UUID string like 'my-session', a UUID with wrong formatting (missing dashes, wrong length, non-hex characters), an empty string after trimming, or a URL branch that never produced a valid UUID.","commonSituations":"Users pasting a conversation title, a database row id, or a shortened link; typing the UUID by hand and dropping a character; using an uppercase-hex id from another system that fails the strict regex.","solutions":["Get the real session UUID from the Grok conversation URL (/c/<uuid>) and pass that.","Verify the id is 36 characters with 4 hyphens and only hex digits (UUID v4 style), e.g. 7c4197f2-10a1-4ebb-a84a-fea89f4f1d06.","If you have a full grok.com/c/ URL, pass it as-is — the parser extracts the UUID for you.","Run the UUID through a quick regex check /^[0-9a-f]{8}-[0-9a-f]{4}-...$/ before calling."],"exampleFix":"// before\nconst id = parseGrokSessionId('7c4197f210a14ebba84afea89f4f1d06'); // no dashes\n// after\nconst id = parseGrokSessionId('7c4197f2-10a1-4ebb-a84a-fea89f4f1d06');","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!UUID_RE.test(input) && !isGrokConversationUrl(input)) {\n  throw new Error(`id must be a UUID or grok.com/c/ URL, got: ${input}`);\n}","typeGuard":"function isUuid(s) {\n  return typeof s === 'string' &&\n    /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);\n}","tryCatchPattern":"try {\n  const id = parseGrokSessionId(raw);\n} catch (e) {\n  if (/not a valid Grok session ID/.test(e.message)) {\n    console.error(`'${raw}' is not a UUID. Example: 7c4197f2-10a1-4ebb-a84a-fea89f4f1d06`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always source ids from the /c/<uuid> URL rather than typing them","Validate UUID shape before calling","Lowercase and trim inputs","Store ids in config in UUID form only"],"tags":["argument-validation","uuid","cli"],"backgroundTag":"invalid-uuid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}