jackwener/OpenCLI · error · ConfigError
Run `opencli slock server-use <slug>` to set the active serv
Error message
Run `opencli slock server-use <slug>` to set the active server.
What it means
When the in-page snippet reports a 'no-server' envelope, dispatchEvaluateResult throws ConfigError with the message 'Run `opencli slock server-use <slug>` to set the active server.' The command is server-scoped but no active server is configured in the CLI.
Source
Thrown at clis/slock/errors.js:20
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
- Run `opencli slock server-use <slug>` to set the active server
- Run `opencli slock server-list` first if you don't know the slug
- Pass `--server <slug-or-id>` on the command to override the active server for one invocation
Example fix
// before opencli slock dm-list // after opencli slock server-use my-workspace opencli slock dm-list
Defensive patterns
Strategy: validation
Validate before calling
const cfg = JSON.parse(fs.readFileSync(activeServerConfigPath, 'utf8'));
if (!cfg.activeServer) { console.error('No active server. Run: opencli slock server-use <slug>'); process.exit(2); } Type guard
const hasActiveServer = (cfg) => typeof cfg?.activeServer === 'string' && cfg.activeServer.length > 0;
Try / catch
try { await slockCommand(); } catch (e) { if (e instanceof ConfigError) { console.error(e.message); cp.execSync('opencli slock server-use <slug>'); return retryOnce(slockCommand); } throw e; } Prevention
- Run `server-use` as part of environment/CI setup
- Pass --server explicitly in scripts to avoid relying on active-server state
- Keep the CLI config file out of cleanup routines
When it happens
Trigger: Running any server-scoped slock command (dm-list, inbox, channel-members, etc.) before ever selecting a server, or after the active server config entry was removed.
Common situations: Fresh install of the CLI with config not initialized; switching machines or profiles and forgetting to re-select the active server; config file cleaned/reset.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/354cc14253403e6f.
Report an issue: GitHub.