jackwener/OpenCLI · error · CommandExecutionError

${data.error}

Error message

${data.error}

What it means

The v2ex me command evaluates a DOM-extraction script on the homepage; when that script returns {error: ...} the command wraps it in CommandExecutionError (with debug title/body logged when OPENCLI_VERBOSE is set). It indicates the profile page was not in the expected logged-in state, so username/balance/notifications could not be extracted.

Source

Thrown at clis/v2ex/me.js:96

            debug_title: document.title,
            debug_body: document.body.innerText.substring(0, 200).replace(/\\n/g, ' ')
          };
        }

        return {
          username,
          balance,
          unread_notifications,
          daily_reward_ready: daily_reward_ready ? '是' : '否'
        };
      }
    `);
        if (data.error) {
            if (process.env.OPENCLI_VERBOSE) {
                console.error(`[opencli:v2ex:debug] Page Title: ${data.debug_title}`);
                console.error(`[opencli:v2ex:debug] Page Body: ${data.debug_body}`);
            }
            throw new CommandExecutionError(data.error);
        }
        return [data];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with OPENCLI_VERBOSE=1 to inspect debug_title/debug_body and see which page actually loaded.
  2. Re-login to V2EX (run the v2ex auth flow) so the homepage renders the logged-in top bar.
  3. Manually clear any Cloudflare challenge in the automation browser, then retry.
  4. Update the extraction script selectors in clis/v2ex/me.js if V2EX changed its DOM.

Example fix

// before
$ opencli v2ex me   # CommandExecutionError: <page error>
// after
$ OPENCLI_VERBOSE=1 opencli v2ex me
$ opencli v2ex login && opencli v2ex me
Defensive patterns

Strategy: try-catch

Validate before calling

OPENCLI_VERBOSE=1 opencli v2ex me   # reveals which page actually loaded via debug_title/debug_body

Type guard

function extractionFailed(data) {
  return !!data && typeof data === 'object' && typeof data.error === 'string' && data.error.length > 0;
}

Try / catch

try {
  const [me] = await runMe();
} catch (e) {
  console.error('v2ex me failed:', e.message);
  // re-login to v2ex and clear any challenge page, then retry
}

Prevention

When it happens

Trigger: The in-page script on https://www.v2ex.com/ returns an explicit error — typically because the top-bar member link or balance elements are absent (anonymous session, Cloudflare page, or changed V2EX markup).

Common situations: Expired A2 cookie causing logged-out homepage; Cloudflare challenge surviving the 5-attempt wait loop; V2EX DOM redesign breaking the extraction selectors; account restricted page rendered instead of the normal homepage.

Related errors


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