{"record":{"id":"12683eda35cc7c19","repo":"jackwener/OpenCLI","slug":"upgrade-click-failed","errorCode":null,"errorMessage":"upgrade click failed","messagePattern":"upgrade click failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/kimi/audit-extras.js","lineNumber":99,"sourceCode":"        await ensureOnKimi(page);\n        const res = await page.evaluate(`(() => {\n      ${IS_VISIBLE_JS}\n      const btns = Array.from(document.querySelectorAll('button, [role=\"button\"], a')).filter(isVisible);\n      const target = btns.find((b) => {\n        const t = (b.innerText || b.textContent || '').trim();\n        return /^Upgrade$|^升级|^会员计划|^开通会员/i.test(t) && t.length < 30;\n      });\n      if (!target) return { ok: false, reason: 'No Upgrade-style button visible.' };\n      const r = target.getBoundingClientRect();\n      const opts = { bubbles: true, cancelable: true, clientX: r.x + r.width/2, clientY: r.y + r.height/2 };\n      target.dispatchEvent(new PointerEvent('pointerdown', opts));\n      target.dispatchEvent(new MouseEvent('mousedown', opts));\n      target.dispatchEvent(new PointerEvent('pointerup', opts));\n      target.dispatchEvent(new MouseEvent('mouseup', opts));\n      target.click();\n      return { ok: true };\n    })()`);\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'upgrade click failed', '');\n        await page.wait(0.6);\n        return [{ Status: 'clicked' }];\n    },\n});\n\n// -------- dismiss-banner --------\ncli({\n    site: 'kimi',\n    name: 'dismiss-banner',\n    access: 'write',\n    description: 'Close any visible sidebar banner (e.g., \"Make a Review & Earn Credit\", \"获取应用程序\") by clicking its Close svg.',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [],\n    columns: AUDIT_EXTRA_COLUMNS,","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/audit-extras.js#L81-L117","documentation":"The kimi upgrade command searches visible buttons for text matching /^Upgrade$|^升级|^会员计划|^开通会员/i and simulates a full click sequence. If no such button is found the script returns {ok:false,reason:'No Upgrade-style button visible.'} and the command throws CommandExecutionError('upgrade click failed') (message replaced by the script's reason when present).","triggerScenarios":"Running `kimi upgrade` when the sidebar Upgrade/升级 button is not visible: the user is already on a paid plan, the sidebar is collapsed or not yet rendered after ensureOnKimi, a banner/dialog covers the layout, or Kimi changed the button text.","commonSituations":"Premium subscribers no longer see an Upgrade button; slow page load means the 0.6s-tolerant script ran before hydration; Kimi A/B test renamed the button (e.g. '升级到会员'); mobile layout where the sidebar is hidden.","solutions":["Check in a real browser whether your account shows an Upgrade button at all — if you're already upgraded, this error is expected","Re-run after waiting longer for the page to fully render (increase waits before the evaluate)","Open the page and check the actual button text; if Kimi renamed it, extend the regex in the selector script","Maximize the viewport / expand the collapsed sidebar so the button is visible before running"],"exampleFix":"// before\nconst res = await page.evaluate(upgradeClickScript);\n// after\nawait page.wait(2); // ensure sidebar hydrated\nconst res = await page.evaluate(upgradeClickScript);\nif (!res?.ok) throw new CommandExecutionError(res?.reason || 'upgrade click failed', `Try widening the text match regex, or check plan status manually`);","handlingStrategy":"fallback","validationCode":"const hasUpgrade = await page.evaluate(`Array.from(document.querySelectorAll('button, [role=\"button\"], a')).some(b => /^(Upgrade|升级|会员计划|开通会员)/i.test((b.innerText||'').trim()))`);\nif (!hasUpgrade) console.log('No upgrade button — likely already premium; skipping');","typeGuard":"function isClickResult(res) { return res != null && typeof res === 'object' && typeof res.ok === 'boolean'; }","tryCatchPattern":"try {\n  await runCli('kimi upgrade');\n} catch (e) {\n  if (/upgrade click failed|No Upgrade-style button/i.test(e.message)) console.warn('Upgrade button not present — possibly already upgraded');\n  else throw e;\n}","preventionTips":["Check the account's plan status before invoking upgrade","Widen the button-text regex to cover Kimi's localized variants","Wait for sidebar hydration before querying buttons","Treat absence of the button as success in cleanup scripts"],"tags":["browser-automation","dom-selector","ui-change"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}