jackwener/OpenCLI · error · ArgumentError
lobsters domain is required (e.g. "github.com" or "arxiv.org
Error message
lobsters domain is required (e.g. "github.com" or "arxiv.org")
What it means
Thrown by requireDomain() when a domain argument is missing, null, or an empty/whitespace string. The lobsters CLI requires a hostname to build the https://lobste.rs/domains/<domain>.json request. It throws ArgumentError early instead of firing a doomed network call.
Source
Thrown at clis/lobsters/domain.js:15
// lobsters domain — list Lobste.rs stories submitted from a specific domain.
//
// Hits the public `https://lobste.rs/domains/<domain>.json` endpoint
// (returns the same per-story shape used by `lobsters tag` / `lobsters
// hot`). Lets agents ask "what did Lobsters surface from github.com /
// blog.cloudflare.com / arxiv.org lately?".
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
const DOMAIN_PATTERN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+$/i;
function requireDomain(value) {
const s = String(value ?? '').trim().toLowerCase();
if (!s) {
throw new ArgumentError('lobsters domain is required (e.g. "github.com" or "arxiv.org")');
}
if (!DOMAIN_PATTERN.test(s)) {
throw new ArgumentError(`lobsters domain "${value}" is not a valid hostname`);
}
return s;
}
function requireBoundedInt(value, defaultValue, maxValue) {
const raw = value ?? defaultValue;
const n = typeof raw === 'number' ? raw : Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError('lobsters limit must be a positive integer');
}
if (n > maxValue) {
throw new ArgumentError(`lobsters limit must be <= ${maxValue}`);
}
return n;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a hostname argument, e.g. domain('github.com') or `lobsters domain github.com`
- Set/verify the environment variable or config key that supplies the domain before invoking
- Check for typos or destructuring of an undefined options field
Example fix
// before await cli.domain(opts.domain); // opts.domain is undefined // after const domain = opts.domain ?? 'github.com'; await cli.domain(domain);
Defensive patterns
Strategy: validation
Validate before calling
function hasDomain(v) {
const s = String(v ?? '').trim().toLowerCase();
return s.length > 0;
}
if (!hasDomain(opts.domain)) throw new Error('domain is required before calling cli.domain()'); Type guard
function hasDomain(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await cli.domain(opts.domain);
} catch (err) {
if (err instanceof ArgumentError && /domain is required/.test(err.message)) {
console.error('Usage: lobsters domain <hostname>, e.g. github.com');
process.exitCode = 2;
} else throw err;
} Prevention
- Make the domain a required CLI argument with a usage check before dispatch
- Fail fast on missing env/config at startup, not at call time
- Default destructured options: const { domain = 'github.com' } = opts
When it happens
Trigger: Calling domain() / requireDomain() with undefined, null, '', ' ', or a value that String()-coerces to an empty string (e.g. process.env.LOBSTERS_DOMAIN unset).
Common situations: Missing CLI argument (e.g. `lobsters domain` with no value); unset or misspelled environment variable; passing an object/array whose String() coercion yields '[object Object]' is caught by the regex case, but empty options objects coerce to ''.
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
- symbol is required
- coingecko derivatives limit must be a positive integer
- Either --product-id or --url is required
- --from and --to must differ (got ${fromCity})
- --city is required (numeric city ID from `ctrip search` or `
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/dcdfd0abb81849bf.
Report an issue: GitHub.