jackwener/OpenCLI · error · ArgumentError

id

id

Error message

must be a non-empty session ID or qianwen.com chat URL

What it means

parseQianwenSessionId in clis/qwen/utils.js throws ArgumentError('id', 'must be a non-empty session ID or qianwen.com chat URL') when the input is null, undefined, or trims to an empty string. The session id can be either a 32-char hex ID or a full chat URL; an empty value cannot identify any conversation.

Source

Thrown at clis/qwen/utils.js:109

    if (hint && isVisible(hint)) return false;
    return true;
  })()`);
    return Boolean(result);
}

export async function getCurrentSessionId(page) {
    const url = await page.evaluate('window.location.href').catch(() => '');
    if (typeof url !== 'string') return '';
    const match = url.match(/\/chat\/([A-Za-z0-9_-]+)/);
    return match ? match[1] : '';
}

const QIANWEN_SESSION_ID_RE = /^[a-f0-9]{32}$/i;

export function parseQianwenSessionId(input) {
    const raw = String(input ?? '').trim();
    if (!raw) {
        throw new ArgumentError('id', 'must be a non-empty session ID or qianwen.com chat URL');
    }
    // Anchor the right-hand side so a 33+ hex URL does not silently truncate
    // to its first 32 chars. Acceptable terminators: end-of-string, path slash,
    // query string, or fragment. Without the boundary,
    // `https://www.qianwen.com/chat/<33 hex>` would parse as a valid 32-char
    // ID instead of being rejected — opening the wrong conversation is a
    // worse failure mode than throwing.
    const urlMatch = raw.match(/qianwen\.com\/chat\/([a-f0-9]{32})(?:[/?#]|$)/i);
    const candidate = urlMatch ? urlMatch[1] : raw;
    if (!QIANWEN_SESSION_ID_RE.test(candidate)) {
        throw new ArgumentError(
            'id',
            `not a valid Qianwen session ID (got "${input}"); expected a 32-char hex ID like "abcd1234ef567890abcd1234ef567890" or a full https://www.qianwen.com/chat/<id> URL`,
        );
    }
    return candidate.toLowerCase();
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Supply the 32-char hex session ID via --id, e.g. --id abcd1234ef567890abcd1234ef567890
  2. Or pass the full chat URL: --id 'https://www.qianwen.com/chat/<32-hex>'
  3. Check that the variable/config feeding --id is populated (echo it before running)
  4. If the ID came from a previous command's output, verify that command actually succeeded

Example fix

// before
SESSION_ID=""
clis qwen history --id "$SESSION_ID"
// after
SESSION_ID="abcd1234ef567890abcd1234ef567890"
clis qwen history --id "$SESSION_ID"
Defensive patterns

Strategy: validation

Validate before calling

function requireSessionId(argv) {
  const id = (argv.id || '').trim();
  if (!id) throw new Error('Missing --id: pass a 32-char hex session ID or a qianwen.com/chat URL');
  return id;
}

Type guard

const hasSessionId = (kwargs) =>
  typeof kwargs?.id === 'string' && kwargs.id.trim().length > 0;

Try / catch

try {
  await runQianwenHistory({ id });
} catch (e) {
  if (e instanceof ArgumentError && /non-empty session ID/.test(e.message)) {
    console.error('Provide --id <32-hex> or --id "https://www.qianwen.com/chat/<id>"');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the history/session command without --id; passing --id '' or whitespace; a variable holding the ID is unset/empty in a wrapper script; programmatically calling sessionId() with undefined.

Common situations: Forgetting the required --id flag; empty environment variables interpolated into the command; scripts that derive the ID from a previous command whose output was empty due to an earlier failure.

Related errors


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