{"record":{"id":"be65257827d27265","repo":"jackwener/OpenCLI","slug":"boss-name-cannot-be-empty","errorCode":null,"errorMessage":"boss ${name} cannot be empty","messagePattern":"boss (.+?) cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/boss/utils.js","lineNumber":33,"sourceCode":" */\nexport function requirePage(page) {\n    if (!page)\n        throw new CommandExecutionError('Browser page required');\n}\nexport function readPositiveInteger(raw, name, fallback, max) {\n    const value = raw === undefined || raw === null || raw === '' ? fallback : Number(raw);\n    if (!Number.isInteger(value) || value < 1) {\n        throw new ArgumentError(`boss ${name} must be a positive integer`);\n    }\n    if (max !== undefined && value > max) {\n        throw new ArgumentError(`boss ${name} must be <= ${max}`);\n    }\n    return value;\n}\nexport function readRequiredString(raw, name) {\n    const value = String(raw ?? '').trim();\n    if (!value) {\n        throw new ArgumentError(`boss ${name} cannot be empty`);\n    }\n    return value;\n}\n/**\n * Navigate to BOSS chat page and wait for it to settle.\n * This establishes the cookie context needed for subsequent API calls.\n */\nexport async function navigateToChat(page, waitSeconds = 2) {\n    await page.goto(CHAT_URL);\n    await page.wait({ time: waitSeconds });\n}\n/**\n * Navigate to a custom BOSS page (for search/detail that use different pages).\n */\nexport async function navigateTo(page, url, waitSeconds = 1) {\n    await page.goto(url);\n    await page.wait({ time: waitSeconds });\n}","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/utils.js#L15-L51","documentation":"readRequiredString normalizes a raw option with String(raw ?? '').trim() and throws ArgumentError when the result is empty. It guards required identifiers (uid, jobId) so the library never builds API URLs with blank IDs. A missing, empty-string, or whitespace-only value triggers it.","triggerScenarios":"Running a command that requires --uid or --jobId but omitting the flag, passing --uid \"\" or --uid \"   \", or passing a value that is undefined/null after option parsing.","commonSituations":"Forgetting the flag in a script; an upstream variable that is empty or unset interpolated into the CLI invocation; shell quoting producing an empty argument (e.g. --uid \"$UNSET_VAR\").","solutions":["Supply the required --uid / --jobId value on the command line.","Check that the shell variable feeding the flag is actually set and non-blank.","Verify option parsing (e.g. commander/yargs config) marks the option required so it fails earlier with a clearer message."],"exampleFix":"// before\ncli friend-detail --uid \"$UID\"\n// after\nUID=abc123 cli friend-detail --uid \"$UID\"   # or guard: [ -n \"$UID\" ] || exit 1","handlingStrategy":"validation","validationCode":"function assertRequiredString(raw, name) {\n  const v = String(raw ?? '').trim();\n  if (!v) throw new Error(`${name} cannot be empty`);\n  return v;\n}\nassertRequiredString(process.env.BOSS_UID, 'uid');","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cli.friendDetail({ uid });\n} catch (e) {\n  if (e instanceof ArgumentError && /cannot be empty/.test(e.message)) {\n    console.error(`Missing required ${e.message.match(/boss (\\w+)/)?.[1]}; pass it explicitly.`);\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","preventionTips":["Mark required options required in your CLI parser so it fails with usage help","Validate shell variables are non-blank before interpolating into flags","Trim user-supplied ids before passing them"],"tags":["validation","cli-options","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}