jackwener/OpenCLI · error · CommandExecutionError

upgrade click failed

Error message

upgrade click failed

What it means

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).

Source

Thrown at clis/kimi/audit-extras.js:99

        await ensureOnKimi(page);
        const res = await page.evaluate(`(() => {
      ${IS_VISIBLE_JS}
      const btns = Array.from(document.querySelectorAll('button, [role="button"], a')).filter(isVisible);
      const target = btns.find((b) => {
        const t = (b.innerText || b.textContent || '').trim();
        return /^Upgrade$|^升级|^会员计划|^开通会员/i.test(t) && t.length < 30;
      });
      if (!target) return { ok: false, reason: 'No Upgrade-style button visible.' };
      const r = target.getBoundingClientRect();
      const opts = { bubbles: true, cancelable: true, clientX: r.x + r.width/2, clientY: r.y + r.height/2 };
      target.dispatchEvent(new PointerEvent('pointerdown', opts));
      target.dispatchEvent(new MouseEvent('mousedown', opts));
      target.dispatchEvent(new PointerEvent('pointerup', opts));
      target.dispatchEvent(new MouseEvent('mouseup', opts));
      target.click();
      return { ok: true };
    })()`);
        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'upgrade click failed', '');
        await page.wait(0.6);
        return [{ Status: 'clicked' }];
    },
});

// -------- dismiss-banner --------
cli({
    site: 'kimi',
    name: 'dismiss-banner',
    access: 'write',
    description: 'Close any visible sidebar banner (e.g., "Make a Review & Earn Credit", "获取应用程序") by clicking its Close svg.',
    domain: KIMI_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [],
    columns: AUDIT_EXTRA_COLUMNS,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check in a real browser whether your account shows an Upgrade button at all — if you're already upgraded, this error is expected
  2. Re-run after waiting longer for the page to fully render (increase waits before the evaluate)
  3. Open the page and check the actual button text; if Kimi renamed it, extend the regex in the selector script
  4. Maximize the viewport / expand the collapsed sidebar so the button is visible before running

Example fix

// before
const res = await page.evaluate(upgradeClickScript);
// after
await page.wait(2); // ensure sidebar hydrated
const res = await page.evaluate(upgradeClickScript);
if (!res?.ok) throw new CommandExecutionError(res?.reason || 'upgrade click failed', `Try widening the text match regex, or check plan status manually`);
Defensive patterns

Strategy: fallback

Validate before calling

const hasUpgrade = await page.evaluate(`Array.from(document.querySelectorAll('button, [role="button"], a')).some(b => /^(Upgrade|升级|会员计划|开通会员)/i.test((b.innerText||'').trim()))`);
if (!hasUpgrade) console.log('No upgrade button — likely already premium; skipping');

Type guard

function isClickResult(res) { return res != null && typeof res === 'object' && typeof res.ok === 'boolean'; }

Try / catch

try {
  await runCli('kimi upgrade');
} catch (e) {
  if (/upgrade click failed|No Upgrade-style button/i.test(e.message)) console.warn('Upgrade button not present — possibly already upgraded');
  else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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