jackwener/OpenCLI · error · CommandExecutionError

Unexpected Amazon probe: ${JSON.stringify(probe)}

Error message

Unexpected Amazon probe: ${JSON.stringify(probe)}

What it means

CommandExecutionError thrown when the in-page identity probe returns neither {kind:'auth'} nor {ok:true} — e.g. null, undefined, or an object with unexpected shape. This is a defensive branch for probe results outside the two expected outcomes, usually indicating the evaluate() script failed to run or returned something unparsable rather than a clean auth verdict.

Source

Thrown at clis/amazon/auth.js:36

      const navLink = document.querySelector('#nav-link-accountList');
      if (!navLink) {
        return { kind: 'auth', detail: 'Amazon header missing nav-link-accountList — layout changed or robot challenge' };
      }
      const greeting = (navLink.querySelector('.nav-line-1, #nav-link-accountList-nav-line-1') || {}).textContent || '';
      const trimmed = greeting.trim();
      if (/sign\\s*in/i.test(trimmed)) {
        return { kind: 'auth', detail: 'Amazon header shows "Hello, sign in" — anonymous' };
      }
      const m = trimmed.match(/^Hello,?\\s+(.+)$/i);
      const name = m ? m[1].trim() : '';
      if (!name) {
        return { kind: 'auth', detail: 'Amazon greeting unparseable: ' + trimmed };
      }
      return { ok: true, user_name: name };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('amazon.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Amazon probe: ${JSON.stringify(probe)}`);
  return { user_name: probe.user_name };
}

registerSiteAuthCommands({
  site: 'amazon',
  domain: 'amazon.com',
  loginUrl: 'https://www.amazon.com/ap/signin?openid.return_to=https%3A%2F%2Fwww.amazon.com%2F&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0',
  columns: ['user_name'],
  quickCheck: hasAmazonSessionCookies,
  verify: verifyAmazonIdentity,
  poll: async (page) => {
    if (!await hasAmazonSessionCookies(page)) {
      throw new AuthRequiredError('amazon.com', 'Waiting for Amazon at-main / x-main cookie');
    }
    return verifyAmazonIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after opening amazon.com manually and dismissing any captcha/robot interstitial
  2. Ensure the shared Chrome page stays open and is not navigated/closed during the verify run
  3. Read the JSON in the message to see exactly what the probe returned and reproduce that page state manually
  4. If it reproduces on a normal homepage, file a bug with the embedded probe payload — the probe script likely needs to handle a new Amazon layout
Defensive patterns

Strategy: retry

Try / catch

for (let i = 0; i < 3; i++) {
  try {
    return await opencli.call('amazon auth verify');
  } catch (e) {
    if (/Unexpected Amazon probe/.test(e.message)) { await sleep(2000); continue; }
    throw e;
  }
}
throw new Error('amazon verify kept returning unexpected probe results');

Prevention

When it happens

Trigger: verifyAmazonIdentity calls page.evaluate with the probe IIFE and gets back null/undefined (page navigation destroyed the execution context, evaluate string unsupported) or a value lacking both kind:'auth' and ok:true — then `JSON.stringify(probe)` is embedded in the thrown message.

Common situations: Homepage redirected mid-evaluate (robot check, captcha interstitial) so the script context is destroyed; browser page crashed or closed; Amazon served a page where the script threw before returning; puppeteer-style evaluate returning undefined because the page blocked script execution.

Related errors


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