jackwener/OpenCLI · error · ArgumentError
steam ${label} cannot be empty
Error message
steam ${label} cannot be empty What it means
requireString is the Steam adapter's generic non-empty-string validator; it throws ArgumentError whenever a labeled input trims to an empty string. It guards commands like receipt, amount, and date from receiving missing or blank arguments.
Source
Thrown at clis/steam/utils.js:11
// Shared helpers for the steam adapters that hit Steam's storefront JSON
// endpoints (no browser).
import { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
export const STEAM_STORE = 'https://store.steampowered.com';
const UA = 'opencli-steam-adapter (+https://github.com/jackwener/opencli)';
export function requireString(value, label) {
const s = String(value ?? '').trim();
if (!s) {
throw new ArgumentError(`steam ${label} cannot be empty`);
}
return s;
}
export function requireCountryCode(value, defaultValue = 'us') {
const raw = value === undefined || value === null ? defaultValue : value;
const code = String(raw).trim().toLowerCase();
if (!/^[a-z]{2}$/.test(code)) {
throw new ArgumentError(
`steam currency must be a two-letter storefront country code (got "${value}")`,
'Examples: us, cn, jp, de. This controls Steam regional pricing and availability.',
);
}
return code;
}
export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;View on GitHub (pinned to 49907e53dc)
Solutions
- Supply the missing argument with a non-empty value
- Check that the environment variable or flag feeding the value is actually set
- Add pre-validation in the caller before invoking the command
- Handle ArgumentError to print usage help instead of a raw failure
Example fix
// before const receipt = args.receipt; // undefined // after const receipt = requireString(args.receipt ?? process.env.RECEIPT_PATH, 'receipt');
Defensive patterns
Strategy: validation
Validate before calling
function requireNonEmpty(v, label) {
const s = String(v ?? '').trim();
if (!s) throw new Error(`${label} is required`);
return s;
} Type guard
function isNonEmptyString(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await cmd({ receipt: value });
} catch (e) {
if (e instanceof ArgumentError && /cannot be empty/.test(e.message)) {
console.error('Missing value:', e.message); // print usage
} else throw e;
} Prevention
- Validate CLI flags/env vars before invoking commands
- Use shell parameter expansion (${VAR:?msg}) to catch unset variables
- Convert empty strings to undefined in config loading
- Add smoke tests covering missing-argument paths
When it happens
Trigger: Passing an empty string, whitespace-only string, null, or undefined to any requireString-guarded argument (receipt, amount, date, normalizeReimbursementInput fields).
Common situations: Unset CLI flags (`--receipt ""`), environment variables that are empty, programmatic callers passing undefined for optional-but-required fields.
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
- steam currency must be a two-letter storefront country code
- steam ${label} must be a positive integer
- steam ${label} must be <= ${maxValue}
- steam app id is required (e.g. "620" for Portal 2)
- bbc topic "${args.topic}" is not supported
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/42a7eeb32a458b2d.
Report an issue: GitHub.