{"record":{"id":"dcdfd0abb81849bf","repo":"jackwener/OpenCLI","slug":"lobsters-domain-is-required-e-g-github-com-or","errorCode":null,"errorMessage":"lobsters domain is required (e.g. \"github.com\" or \"arxiv.org\")","messagePattern":"lobsters domain is required \\(e\\.g\\. \"github\\.com\" or \"arxiv\\.org\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/lobsters/domain.js","lineNumber":15,"sourceCode":"// lobsters domain — list Lobste.rs stories submitted from a specific domain.\n//\n// Hits the public `https://lobste.rs/domains/<domain>.json` endpoint\n// (returns the same per-story shape used by `lobsters tag` / `lobsters\n// hot`). Lets agents ask \"what did Lobsters surface from github.com /\n// blog.cloudflare.com / arxiv.org lately?\".\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\n\nconst 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;\n\nfunction requireDomain(value) {\n    const s = String(value ?? '').trim().toLowerCase();\n    if (!s) {\n        throw new ArgumentError('lobsters domain is required (e.g. \"github.com\" or \"arxiv.org\")');\n    }\n    if (!DOMAIN_PATTERN.test(s)) {\n        throw new ArgumentError(`lobsters domain \"${value}\" is not a valid hostname`);\n    }\n    return s;\n}\n\nfunction requireBoundedInt(value, defaultValue, maxValue) {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError('lobsters limit must be a positive integer');\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`lobsters limit must be <= ${maxValue}`);\n    }\n    return n;\n}","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/lobsters/domain.js#L1-L33","documentation":"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.","triggerScenarios":"Calling domain() / requireDomain() with undefined, null, '', '   ', or a value that String()-coerces to an empty string (e.g. process.env.LOBSTERS_DOMAIN unset).","commonSituations":"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 ''.","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"],"exampleFix":"// before\nawait cli.domain(opts.domain); // opts.domain is undefined\n// after\nconst domain = opts.domain ?? 'github.com';\nawait cli.domain(domain);","handlingStrategy":"validation","validationCode":"function hasDomain(v) {\n  const s = String(v ?? '').trim().toLowerCase();\n  return s.length > 0;\n}\nif (!hasDomain(opts.domain)) throw new Error('domain is required before calling cli.domain()');","typeGuard":"function hasDomain(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cli.domain(opts.domain);\n} catch (err) {\n  if (err instanceof ArgumentError && /domain is required/.test(err.message)) {\n    console.error('Usage: lobsters domain <hostname>, e.g. github.com');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["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"],"tags":["argument-error","missing-argument","cli","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}