jackwener/OpenCLI · error · ArgumentError
input required: slug or UUID
Error message
input required: slug or UUID
What it means
The command's positional `input` argument is required; the func trims the raw string and throws ArgumentError when it is empty. Acceptable input is a server slug, a '#slug', or a UUID id.
Source
Thrown at clis/slock/server-use.js:21
import { ArgumentError } from '@jackwener/opencli/errors';
import { dispatchEvaluateResult } from './errors.js';
import { SLOCK_SITE, SLOCK_DOMAIN, SLOCK_HOME_URL, SLOCK_API_BASE } from './shared.js';
import { UUID_RE } from './resolve.js';
cli({
site: SLOCK_SITE,
name: 'server-use',
access: 'write',
description: 'Set the active slock server (writes localStorage.slock_last_server_slug)',
domain: SLOCK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
args: [{ name: 'input', positional: true, required: true, help: 'server slug, "#slug", or UUID id' }],
columns: ['id', 'slug', 'name', 'written'],
func: async (page, kwargs) => {
const raw = String(kwargs.input ?? '').trim();
if (!raw) throw new ArgumentError('input required: slug or UUID');
const isUuid = UUID_RE.test(raw);
const slug = raw.replace(/^#/, '').toLowerCase();
const slugJson = JSON.stringify(slug);
await page.goto(SLOCK_HOME_URL);
const snippet = `
const token = localStorage.getItem('slock_access_token');
if (!token) return { kind: 'auth', detail: 'no token' };
const res = await fetch('${SLOCK_API_BASE}/servers/', { credentials:'include', headers:{authorization:'Bearer '+token,accept:'application/json'} });
if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/servers/' };
const list = await res.json();
const arr = Array.isArray(list) ? list : (list.servers || list.data || []);
let hit;
if (${isUuid}) hit = arr.find((s) => s.id === ${JSON.stringify(raw)});
else hit = arr.find((s) => (s.slug || '').toLowerCase() === ${slugJson});
if (!hit) {
const choices = arr.map((s) => s.slug).filter(Boolean).join(', ');
return { kind: 'unresolvable', detail: 'no server matches ' + ${JSON.stringify(raw)} + '. Known slugs: ' + choices };
}View on GitHub (pinned to 49907e53dc)
Solutions
- Supply the server slug, #slug, or UUID as the positional argument, e.g. `server-use my-server`.
- Check the shell variable you pass actually contains a value (`echo "$SERVER"`).
- Run the command without arguments first to see usage/help for the accepted input forms.
Example fix
// before
spawn('slock', ['server-use', serverName ?? '']);
// after
if (!serverName) throw new Error('server name not configured');
spawn('slock', ['server-use', serverName]); Defensive patterns
Strategy: validation
Validate before calling
const input = String(process.argv[3] ?? '').trim();
if (!input) {
console.error('usage: server-use <slug | #slug | uuid>');
process.exit(2);
} Type guard
const hasServerInput = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
await cli('server-use', input);
} catch (e) {
if (e instanceof ArgumentError && e.message.startsWith('input required')) {
console.error('Provide a server slug or UUID, e.g. server-use my-server');
process.exitCode = 2;
} else throw e;
} Prevention
- Check required shell variables are non-empty before invoking (${VAR:?msg}).
- Quote arguments to avoid empty-string expansion.
- Keep the active-server value in config so you never call server-use blindly.
When it happens
Trigger: Running `server-use` with no positional argument, or with a value that is only whitespace (spaces/tabs), so String(...).trim() yields ''.
Common situations: Forgetting the argument in a scripted call; a shell variable holding an empty string due to a failed lookup (`SERVER="" server-use $SERVER`); quoting mistakes that pass an empty string.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- lobsters domain is required (e.g. "github.com" or "arxiv.org
- messageId required
- channel required
- title required (non-empty)
- channel required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/dee1a28f2965959c.
Report an issue: GitHub.