jackwener/OpenCLI · error · AuthRequiredError

${r.detail}

Error message

${r.detail}

What it means

dispatchEvaluateResult maps an 'auth' envelope from the in-page snippet to AuthRequiredError, carrying the API's detail message (rendered as ${r.detail}). It means the slock web session is not authenticated — the fetch inside the page got an auth rejection and the snippet bubbled that up.

Source

Thrown at clis/slock/errors.js:16

import { ArgumentError, AuthRequiredError, CommandExecutionError, ConfigError } from '@jackwener/opencli/errors';
import { SLOCK_DOMAIN } from './shared.js';

// EvaluateResult is the envelope every in-page snippet returns. Kinds:
//   { kind: 'ok', rows, meta? }
//   { kind: 'auth', detail }
//   { kind: 'http', status, where }
//   { kind: 'no-server', detail }
//   { kind: 'unresolvable', detail }
//   { kind: 'no-thread', parent }       // handled by caller, never reaches dispatcher
export function dispatchEvaluateResult(r) {
  switch (r && r.kind) {
    case 'ok':
      return r.rows;
    case 'auth':
      throw new AuthRequiredError(SLOCK_DOMAIN, r.detail);
    case 'http':
      throw new CommandExecutionError(`HTTP ${r.status} from ${r.where}`);
    case 'no-server':
      throw new ConfigError(r.detail, 'Run `opencli slock server-use <slug>` to set the active server.');
    case 'unresolvable':
      throw new ArgumentError(r.detail);
    case 'no-thread':
      // caller decides what to do (returns a 0-row hint); should never reach here
      throw new CommandExecutionError(`no-thread should be handled by caller, not dispatcher: ${r.parent}`);
    default:
      // unknown / null envelope = contract drift; fail loud (reddit precedent)
      throw new CommandExecutionError(`unexpected evaluate envelope: ${JSON.stringify(r)}`);
  }
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to the slock web app in the automated browser session, then rerun the command
  2. Run the slock auth/login command if the CLI provides one to establish a session
  3. Re-check you are pointing at the right server (`opencli slock server-use <slug>`) since auth is per-server scoped
Defensive patterns

Strategy: try-catch

Validate before calling

// verify a session exists before running commands:
// open in the automated browser and confirm you are logged in to SLOCK_DOMAIN
cp.execSync('opencli slock server-use my-workspace');

Type guard

const isAuthError = (e) => e && e.name === 'AuthRequiredError';

Try / catch

try { await slockCommand(); } catch (e) { if (isAuthError(e)) { console.error('Not authenticated — log in to the slock web app, then retry'); process.exit(3); } throw e; }

Prevention

When it happens

Trigger: Running any slock read command (rows, channel actions, data, c, list, thread-state) without being logged in to the SLOCK_DOMAIN in the automated browser; session cookie expired or was cleared.

Common situations: Fresh browser profile with no login; session invalidated server-side (password change, logout elsewhere); cookie expiry after long idle.

Related errors


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