{"record":{"id":"d5958ba6274ab3ca","repo":"jackwener/OpenCLI","slug":"id","errorCode":"id","errorMessage":"must be a non-empty session ID or qianwen.com chat URL","messagePattern":"must be a non-empty session ID or qianwen\\.com chat URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qwen/utils.js","lineNumber":109,"sourceCode":"    if (hint && isVisible(hint)) return false;\n    return true;\n  })()`);\n    return Boolean(result);\n}\n\nexport async function getCurrentSessionId(page) {\n    const url = await page.evaluate('window.location.href').catch(() => '');\n    if (typeof url !== 'string') return '';\n    const match = url.match(/\\/chat\\/([A-Za-z0-9_-]+)/);\n    return match ? match[1] : '';\n}\n\nconst QIANWEN_SESSION_ID_RE = /^[a-f0-9]{32}$/i;\n\nexport function parseQianwenSessionId(input) {\n    const raw = String(input ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError('id', 'must be a non-empty session ID or qianwen.com chat URL');\n    }\n    // Anchor the right-hand side so a 33+ hex URL does not silently truncate\n    // to its first 32 chars. Acceptable terminators: end-of-string, path slash,\n    // query string, or fragment. Without the boundary,\n    // `https://www.qianwen.com/chat/<33 hex>` would parse as a valid 32-char\n    // ID instead of being rejected — opening the wrong conversation is a\n    // worse failure mode than throwing.\n    const urlMatch = raw.match(/qianwen\\.com\\/chat\\/([a-f0-9]{32})(?:[/?#]|$)/i);\n    const candidate = urlMatch ? urlMatch[1] : raw;\n    if (!QIANWEN_SESSION_ID_RE.test(candidate)) {\n        throw new ArgumentError(\n            'id',\n            `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`,\n        );\n    }\n    return candidate.toLowerCase();\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/utils.js#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply the 32-char hex session ID via --id, e.g. --id abcd1234ef567890abcd1234ef567890","Or pass the full chat URL: --id 'https://www.qianwen.com/chat/<32-hex>'","Check that the variable/config feeding --id is populated (echo it before running)","If the ID came from a previous command's output, verify that command actually succeeded"],"exampleFix":"// before\nSESSION_ID=\"\"\nclis qwen history --id \"$SESSION_ID\"\n// after\nSESSION_ID=\"abcd1234ef567890abcd1234ef567890\"\nclis qwen history --id \"$SESSION_ID\"","handlingStrategy":"validation","validationCode":"function requireSessionId(argv) {\n  const id = (argv.id || '').trim();\n  if (!id) throw new Error('Missing --id: pass a 32-char hex session ID or a qianwen.com/chat URL');\n  return id;\n}","typeGuard":"const hasSessionId = (kwargs) =>\n  typeof kwargs?.id === 'string' && kwargs.id.trim().length > 0;","tryCatchPattern":"try {\n  await runQianwenHistory({ id });\n} catch (e) {\n  if (e instanceof ArgumentError && /non-empty session ID/.test(e.message)) {\n    console.error('Provide --id <32-hex> or --id \"https://www.qianwen.com/chat/<id>\"');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Never invoke session commands without --id; make it required in wrapper scripts","Verify the variable feeding --id is populated (echo before running)","Store session IDs in config/env with a startup existence check","When chaining commands, propagate the ID from a prior command's verified output"],"tags":["validation","arguments","session-id"],"backgroundTag":"invalid-session-id","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}