{"record":{"id":"d965db37aaeed383","repo":"jackwener/OpenCLI","slug":"not-a-valid-yuanbao-agentid-convid-pair-got","errorCode":null,"errorMessage":"not a valid Yuanbao \"<agentId>/<convId>\" pair (got \"${input}\"); agentId must be 4-40 word chars, convId must be a UUID","messagePattern":"not a valid Yuanbao \"<agentId>/<convId>\" pair \\(got \"(.+?)\"\\); agentId must be 4-40 word chars, convId must be a UUID","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/shared.js","lineNumber":107,"sourceCode":"            'must be a non-empty Yuanbao chat URL or \"<agentId>/<convId>\" pair',\n        );\n    }\n    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);\n    if (urlMatch) {\n        const [, agentId, convId] = urlMatch;\n        if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) {\n            throw new ArgumentError(\n                'id',\n                `not a valid Yuanbao chat URL (got \"${input}\"); expected https://yuanbao.tencent.com/chat/<agentId>/<convId>`,\n            );\n        }\n        return { agentId, convId: convId.toLowerCase() };\n    }\n    const slashMatch = raw.match(/^([A-Za-z0-9_-]+)\\/([0-9a-f-]{36})$/i);\n    if (slashMatch) {\n        const [, agentId, convId] = slashMatch;\n        if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) {\n            throw new ArgumentError(\n                'id',\n                `not a valid Yuanbao \"<agentId>/<convId>\" pair (got \"${input}\"); agentId must be 4-40 word chars, convId must be a UUID`,\n            );\n        }\n        return { agentId, convId: convId.toLowerCase() };\n    }\n    throw new ArgumentError(\n        'id',\n        `not a valid Yuanbao session reference (got \"${input}\"); pass either a full https://yuanbao.tencent.com/chat/<agentId>/<convId> URL or a bare \"<agentId>/<convId>\" pair. A UUID alone is not enough — Yuanbao requires the agentId.`,\n    );\n}\n\nexport async function getCurrentYuanbaoSessionId(page) {\n    const url = await page.evaluate('window.location.href').catch(() => '');\n    if (typeof url !== 'string') return null;\n    const match = url.match(/yuanbao\\.tencent\\.com\\/chat\\/([A-Za-z0-9_-]+)\\/([0-9a-f-]{36})(?:[/?#]|$)/i);\n    if (!match) return null;\n    const [, agentId, convId] = match;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/shared.js#L89-L125","documentation":"The input matched the bare <agentId>/<convId> pair pattern but one segment failed the stricter regexes: agentId must be 4-40 word characters and convId must be a canonical UUID. Note the loose slashMatch only requires 36 hex/dash chars, so strings like '----...' reach this validation and are rejected here with a precise message.","triggerScenarios":"Passing e.g. 'ab/<uuid>' (agentId too short), 'my.agent/<uuid>' (dot not allowed), or 'agent/not-a-uuid' (convId of 36 chars but wrong shape, like dashes-only or a 36-char non-UUID string).","commonSituations":"Users pasting only the conversation UUID with a placeholder prefix; splitting a URL incorrectly (e.g. taking extra path segments into agentId); generating ids from templates with unfilled variables like '${agentId}/${convId}'.","solutions":["Check agentId: 4-40 chars, only [A-Za-z0-9_-]","Check convId: a real UUID, 8-4-4-4-12 hex digits","Get exact AgentId and SessionId values from `yuanbao history` output","Prefer passing the full chat URL — its regex is stricter and validates both segments at once"],"exampleFix":"// before\nawait cli.open('ab/9f8b7c6d-1234-4a5b-8c9d-0e1f2a3b4c5d');\n// after\nawait cli.open('tencent-agent/9f8b7c6d-1234-4a5b-8c9d-0e1f2a3b4c5d');","handlingStrategy":"validation","validationCode":"const [agentId, convId] = String(pair).split('/');\nconst ok = /^[A-Za-z0-9_-]{4,40}$/.test(agentId) &&\n  /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(convId);\nif (!ok) throw new Error('agentId must be 4-40 word chars; convId must be a UUID');","typeGuard":"const isValidPair = (v) => {\n  if (typeof v !== 'string') return false;\n  const [a, c] = v.split('/');\n  return /^[A-Za-z0-9_-]{4,40}$/.test(a || '') && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(c || '');\n};","tryCatchPattern":"try {\n  await cli.yuanbaoOpen(pair);\n} catch (e) {\n  if (e.name === 'ArgumentError' && /agentId must be 4-40/.test(e.message)) {\n    console.error('Check the <agentId>/<convId> pair format');\n  } else throw e;\n}","preventionTips":["Validate both segments before passing the pair","Source AgentId/SessionId from `yuanbao history` output, not hand-typed values","Watch for template variables (e.g. '${agentId}') leaking unfilled into ids"],"tags":["validation","argument-error","session-id"],"backgroundTag":"invalid-session-reference","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}