jackwener/OpenCLI · error · ArgumentError

id not a valid Grok conversation URL (got "${input}"); expec

Error message

id not a valid Grok conversation URL (got "${input}"); expected https://grok.com/c/<id>

What it means

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>.

Source

Thrown at clis/grok/utils.js:52

export function parseGrokSessionId(input) {
    const raw = String(input ?? '').trim();
    if (!raw) {
        throw new ArgumentError('id', 'must be a non-empty session ID or grok.com chat URL');
    }
    let candidate = raw;
    if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) {
        let parsed;
        try {
            parsed = new URL(raw);
        } catch {
            throw new ArgumentError('id', `not a valid Grok URL (got "${input}")`);
        }
        const host = parsed.hostname.toLowerCase();
        const pathMatch = parsed.pathname.match(
            /^\/c\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/?$/i,
        );
        if (parsed.protocol !== 'https:' || (host !== 'grok.com' && !host.endsWith('.grok.com')) || !pathMatch) {
            throw new ArgumentError(
                'id',
                `not a valid Grok conversation URL (got "${input}"); expected https://grok.com/c/<id>`,
            );
        }
        candidate = pathMatch[1];
    }
    if (!GROK_SESSION_ID_RE.test(candidate)) {
        throw new ArgumentError(
            '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`,
        );
    }
    return candidate.toLowerCase();
}

export async function isOnGrok(page) {
    const url = await page.evaluate('window.location.href').catch(() => '');
    if (typeof url !== 'string' || !url) return false;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the conversation on grok.com and copy the URL exactly in the form https://grok.com/c/<uuid>.
  2. If you only have a share link, extract the UUID and pass the bare UUID as the id instead.
  3. If passing a bare id, make sure it is the UUID itself so the URL branch is skipped.
  4. Check the protocol is https, not http.

Example fix

// before
parseGrokSessionId('https://grok.com/share/c/7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')
// after
parseGrokSessionId('https://grok.com/c/7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')
// or
parseGrokSessionId('7c4197f2-10a1-4ebb-a84a-fea89f4f1d06')
Defensive patterns

Strategy: validation

Validate before calling

function isGrokConversationUrl(s) {
  try {
    const u = new URL(s);
    return u.protocol === 'https:' &&
      (u.hostname === 'grok.com' || u.hostname.endsWith('.grok.com')) &&
      /^\/c\/[0-9a-f-]{36}\/?$/i.test(u.pathname);
  } catch { return false; }
}

Type guard

function isGrokConversationUrl(input) {
  if (typeof input !== 'string') return false;
  try {
    const u = new URL(input);
    return u.protocol === 'https:' && u.hostname.endsWith('grok.com') && u.pathname.startsWith('/c/');
  } catch { return false; }
}

Try / catch

try {
  const sessionId = parseGrokSessionId(raw);
} catch (e) {
  if (/expected https:\/\/grok.com\/c/.test(e.message)) {
    // extract UUID from whatever link shape you have and retry
    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);
    if (m) return parseGrokSessionId(m[1]);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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>.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3edc4da91f5ec0bf. Report an issue: GitHub.