jackwener/OpenCLI · error · CommandExecutionError

unexpected /auth/me result: ${JSON.stringify(r)}

Error message

unexpected /auth/me result: ${JSON.stringify(r)}

What it means

This CommandExecutionError is thrown when the /auth/me fetch returns null or an envelope whose kind is neither 'auth' nor 'ok' — i.e. contract drift between what the CLI expects and what the server/page returned. The message includes the JSON-serialized result for debugging.

Source

Thrown at clis/slock/auth-verify.js:12

import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { buildFetchSnippet } from './in-page.js';
import { SLOCK_DOMAIN, SLOCK_HOME_URL } from './shared.js';

// site-auth's whoami sets navigateBefore:false, so verify owns navigation.
export async function verifySlockSession(page) {
  await page.goto(SLOCK_HOME_URL);
  const snippet = buildFetchSnippet({ method: 'GET', path: '/auth/me', serverScoped: false });
  const r = await page.evaluate(`(async () => { ${snippet} })()`);
  if (r && r.kind === 'auth') throw new AuthRequiredError(SLOCK_DOMAIN, r.detail);
  // unknown / null envelope = contract drift; same typed class as dispatchEvaluateResult
  if (!r || r.kind !== 'ok') throw new CommandExecutionError(`unexpected /auth/me result: ${JSON.stringify(r)}`);
  const me = r.rows ?? {};
  return {
    id: me.id ?? null,
    name: me.name ?? me.displayName ?? me.username ?? null,
    email: me.email ?? null,
  };
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the JSON.stringify'd result in the message to see the actual envelope and identify the new shape.
  2. Verify you are on a Slock server version compatible with this CLI; downgrade server or upgrade CLI to realign contracts.
  3. Re-run after confirming network reachability of the API base from the page (proxy/VPN interference).
  4. If kind is genuinely new, extend the snippet/dispatch logic to map it before calling verifySlockSession.
Defensive patterns

Strategy: try-catch

Type guard

const isOkEnvelope = (r) => r != null && typeof r === 'object' && r.kind === 'ok';

Try / catch

try {
  const me = await verifySlockSession(page);
} catch (e) {
  if (e instanceof CommandExecutionError && e.message.includes('unexpected /auth/me result')) {
    console.error('Server envelope drift — check CLI/server version compatibility:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: page.evaluate returns null (page navigated away mid-fetch, script error swallowed), or the server returns a new/unknown envelope kind (e.g. kind:'redirect', kind:'error') not covered by the snippet's contract.

Common situations: A Slock server version change altering the /auth/me envelope, a network/proxy erroring inside the in-page fetch, or the SPA redirecting /auth/me to an HTML page so parsing yields an unexpected shape.

Related errors


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