{"record":{"id":"42a7eeb32a458b2d","repo":"jackwener/OpenCLI","slug":"steam-label-cannot-be-empty","errorCode":null,"errorMessage":"steam ${label} cannot be empty","messagePattern":"steam (.+?) cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/steam/utils.js","lineNumber":11,"sourceCode":"// Shared helpers for the steam adapters that hit Steam's storefront JSON\n// endpoints (no browser).\nimport { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\n\nexport const STEAM_STORE = 'https://store.steampowered.com';\nconst UA = 'opencli-steam-adapter (+https://github.com/jackwener/opencli)';\n\nexport function requireString(value, label) {\n    const s = String(value ?? '').trim();\n    if (!s) {\n        throw new ArgumentError(`steam ${label} cannot be empty`);\n    }\n    return s;\n}\n\nexport function requireCountryCode(value, defaultValue = 'us') {\n    const raw = value === undefined || value === null ? defaultValue : value;\n    const code = String(raw).trim().toLowerCase();\n    if (!/^[a-z]{2}$/.test(code)) {\n        throw new ArgumentError(\n            `steam currency must be a two-letter storefront country code (got \"${value}\")`,\n            'Examples: us, cn, jp, de. This controls Steam regional pricing and availability.',\n        );\n    }\n    return code;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/steam/utils.js#L1-L29","documentation":"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.","triggerScenarios":"Passing an empty string, whitespace-only string, null, or undefined to any requireString-guarded argument (receipt, amount, date, normalizeReimbursementInput fields).","commonSituations":"Unset CLI flags (`--receipt \"\"`), environment variables that are empty, programmatic callers passing undefined for optional-but-required fields.","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"],"exampleFix":"// before\nconst receipt = args.receipt; // undefined\n// after\nconst receipt = requireString(args.receipt ?? process.env.RECEIPT_PATH, 'receipt');","handlingStrategy":"validation","validationCode":"function requireNonEmpty(v, label) {\n  const s = String(v ?? '').trim();\n  if (!s) throw new Error(`${label} is required`);\n  return s;\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cmd({ receipt: value });\n} catch (e) {\n  if (e instanceof ArgumentError && /cannot be empty/.test(e.message)) {\n    console.error('Missing value:', e.message); // print usage\n  } else throw e;\n}","preventionTips":["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"],"tags":["validation","argument","steam"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}