jackwener/OpenCLI · error · ArgumentError

must be a non-empty Yuanbao chat URL or "<agentId>/<convId>"

Error message

must be a non-empty Yuanbao chat URL or "<agentId>/<convId>" pair

What it means

parseYuanbaoSessionId rejects an empty session reference. It trims String(input ?? '') and throws ArgumentError with the id parameter name when nothing remains. The function accepts either a full Yuanbao chat URL or a bare <agentId>/<convId> pair, and '' matches neither.

Source

Thrown at clis/yuanbao/shared.js:87

/**
 * Extract Yuanbao session identity from a raw input.
 *
 * Yuanbao chat URLs are `/chat/<agentId>/<convId>`. Both parts are required
 * to navigate — there is no stable default agentId we can fall back to. So we
 * only accept inputs that resolve a complete `{agentId, convId}` pair:
 *   - full `https://yuanbao.tencent.com/chat/<agentId>/<convId>` URL
 *   - bare slash form `<agentId>/<convId>`
 *
 * A bare convId UUID is rejected with an actionable message — opening the
 * wrong agent silently is a much worse failure mode than throwing.
 *
 * The trailing `(?:[/?#]|$)` boundary in the URL regex prevents over-long
 * suffixes (e.g. `<id>extra`) from silently truncating to a valid-looking ID.
 */
export function parseYuanbaoSessionId(input) {
    const raw = String(input ?? '').trim();
    if (!raw) {
        throw new ArgumentError(
            'id',
            'must be a non-empty Yuanbao chat URL or "<agentId>/<convId>" pair',
        );
    }
    const urlMatch = raw.match(/yuanbao\.tencent\.com\/chat\/([A-Za-z0-9_-]+)\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i);
    if (urlMatch) {
        const [, agentId, convId] = urlMatch;
        if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) {
            throw new ArgumentError(
                'id',
                `not a valid Yuanbao chat URL (got "${input}"); expected https://yuanbao.tencent.com/chat/<agentId>/<convId>`,
            );
        }
        return { agentId, convId: convId.toLowerCase() };
    }
    const slashMatch = raw.match(/^([A-Za-z0-9_-]+)\/([0-9a-f-]{36})$/i);
    if (slashMatch) {
        const [, agentId, convId] = slashMatch;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a full chat URL like https://yuanbao.tencent.com/chat/<agentId>/<convId>
  2. Or pass the bare pair: `<agentId>/<convId>` (convId is a UUID)
  3. If the id comes from a variable/config, check it is non-empty before invoking
  4. Capture a real AgentId/SessionId from `yuanbao history` output first

Example fix

// before
const id = cfg.yuanbaoSession || '';
await cli.open(id);
// after
const id = cfg.yuanbaoSession;
if (!id) throw new Error('yuanbaoSession is not configured');
await cli.open(id);
Defensive patterns

Strategy: validation

Validate before calling

if (!input || !String(input).trim()) {
  throw new Error('session id must be a non-empty Yuanbao chat URL or <agentId>/<convId> pair');
}

Type guard

const hasSessionRef = (v) => typeof v === 'string' && v.trim().length > 0;

Try / catch

try {
  await cli.yuanbaoOpen(id);
} catch (e) {
  if (e.name === 'ArgumentError' && e.param === 'id') {
    console.error('Provide a full chat URL or <agentId>/<convId>');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling a command that resolves a session (open/show) with an empty string, null, or undefined id — e.g. a script variable holding the session id was never set, or a previous history command returned no AgentId to forward.

Common situations: Chaining commands where the upstream lookup failed silently and '' was piped forward; config files with an empty yuanbao.session key; JSON payloads omitting the id field (null/undefined coalesced to '').

Related errors


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