{"record":{"id":"babeb685a5dcd316","repo":"jackwener/OpenCLI","slug":"not-a-valid-yuanbao-chat-url-got-input-exp","errorCode":null,"errorMessage":"not a valid Yuanbao chat URL (got \"${input}\"); expected https://yuanbao.tencent.com/chat/<agentId>/<convId>","messagePattern":"not a valid Yuanbao chat URL \\(got \"(.+?)\"\\); expected https://yuanbao\\.tencent\\.com/chat/<agentId>/<convId>","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/shared.js","lineNumber":96,"sourceCode":" * A bare convId UUID is rejected with an actionable message — opening the\n * wrong agent silently is a much worse failure mode than throwing.\n *\n * The trailing `(?:[/?#]|$)` boundary in the URL regex prevents over-long\n * suffixes (e.g. `<id>extra`) from silently truncating to a valid-looking ID.\n */\nexport function parseYuanbaoSessionId(input) {\n    const raw = String(input ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError(\n            'id',\n            '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(","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/shared.js#L78-L114","documentation":"The input matched the Yuanbao chat URL shape but the extracted agentId or convId failed the stricter AGENT_ID_RE (4-40 word chars) or CONV_ID_RE (canonical UUID) checks. This guards against lookalike URLs whose captured segments would produce unusable ids downstream.","triggerScenarios":"Passing a URL where the agent segment contains disallowed characters (e.g. dots, non-ASCII, CJK) or is shorter than 4 / longer than 40 chars, or where the conversation segment is a malformed UUID (wrong length, invalid hex, extra dashes).","commonSituations":"Hand-edited or truncated URLs copied from logs; localized Yuanbao URLs with encoded agent ids; IDs from an older Yuanbao URL scheme that no longer match the current format; typos when constructing the URL programmatically.","solutions":["Copy the chat URL directly from the browser address bar rather than editing it by hand","Verify agentId is 4-40 chars of [A-Za-z0-9_-] and convId is a standard UUID","Fetch a fresh, known-good reference via `yuanbao history` and use its AgentId/SessionId","If your id is a legacy format, obtain a new conversation link from the Yuanbao UI"],"exampleFix":"// before\nawait cli.open('https://yuanbao.tencent.com/chat/ab/12345');\n// after\nawait cli.open('https://yuanbao.tencent.com/chat/tencent-yuanbao-agent/9f8b7c6d-1234-4a5b-8c9d-0e1f2a3b4c5d');","handlingStrategy":"validation","validationCode":"const AGENT_RE = /^[A-Za-z0-9_-]{4,40}$/;\nconst CONV_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst m = url.match(/yuanbao\\.tencent\\.com\\/chat\\/([^/?#]+)\\/([^/?#]+)/i);\nif (!m || !AGENT_RE.test(m[1]) || !CONV_RE.test(m[2])) throw new Error('invalid Yuanbao chat URL');","typeGuard":"const isValidYuanbaoUrl = (v) => {\n  if (typeof v !== 'string') return false;\n  const m = v.match(/yuanbao\\.tencent\\.com\\/chat\\/([A-Za-z0-9_-]+)\\/([0-9a-f-]{36})(?:[/?#]|$)/i);\n  return !!m && /^[A-Za-z0-9_-]{4,40}$/.test(m[1]);\n};","tryCatchPattern":"try {\n  await cli.yuanbaoOpen(url);\n} catch (e) {\n  if (e.name === 'ArgumentError' && /not a valid Yuanbao chat URL/.test(e.message)) {\n    console.error('Re-copy the URL from the browser address bar');\n  } else throw e;\n}","preventionTips":["Copy URLs verbatim from the browser address bar; never hand-edit ids","Validate agentId (4-40 word chars) and convId (canonical UUID) at ingestion time","Regenerate references if Yuanbao changed URL formats"],"tags":["validation","argument-error","url-parsing","session-id"],"backgroundTag":"invalid-session-reference","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}