{"record":{"id":"a947d1702086ce61","repo":"jackwener/OpenCLI","slug":"upwork-label-cannot-be-empty","errorCode":null,"errorMessage":"upwork ${label} cannot be empty","messagePattern":"upwork (.+?) cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/upwork/utils.js","lineNumber":52,"sourceCode":"    if (value && typeof value === 'object' && !Array.isArray(value) && 'session' in value && 'data' in value) {\n        return value.data;\n    }\n    return value;\n}\n\nexport function isPlainObject(value) {\n    return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction coerceInt(value) {\n    if (value === undefined || value === null || value === '') return NaN;\n    const n = typeof value === 'number' ? value : Number(value);\n    return Number.isFinite(n) && Number.isInteger(n) ? n : NaN;\n}\n\nexport function requireQuery(value, label = 'query') {\n    const q = String(value ?? '').trim();\n    if (!q) throw new ArgumentError(`upwork ${label} cannot be empty`);\n    return q;\n}\n\nexport function requirePositiveInt(value, defaultValue, label) {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`upwork ${label} must be a positive integer`);\n    }\n    return n;\n}\n\nexport function requireBoundedInt(value, defaultValue, min, max, label) {\n    const n = requirePositiveInt(value, defaultValue, label);\n    if (n < min) throw new ArgumentError(`upwork ${label} must be >= ${min}`);\n    if (n > max) throw new ArgumentError(`upwork ${label} must be <= ${max}`);\n    return n;\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/utils.js#L34-L70","documentation":"An ArgumentError thrown by requireQuery when the supplied query value is empty or whitespace-only after trimming. Every upwork subcommand that needs a search term funnels through this guard so the CLI never issues a query with a blank search string.","triggerScenarios":"Calling an upwork command with an empty string, only-whitespace string, null, or undefined for the query argument - e.g. query: '' or the shell variable holding the query being unset.","commonSituations":"An unset/empty shell variable interpolated into the command; reading the query from config or a file that came back empty; forgetting to pass the positional argument; a script piping an empty line as the query.","solutions":["Pass a non-empty query string to the command.","If the query comes from a variable or file, check it is populated before invoking (e.g. [ -n \"$QUERY\" ] || exit 1).","Trim user input yourself and re-prompt if it is blank.","Review the command's argument order in case the query positional was skipped."],"exampleFix":"// before\nawait cli.search(process.env.QUERY) // QUERY is unset -> ArgumentError\n// after\nconst q = (process.env.QUERY || '').trim();\nif (!q) throw new Error('QUERY env var is required');\nawait cli.search(q)","handlingStrategy":"validation","validationCode":"function requireQuery(value, label = 'query') {\n  const q = String(value ?? '').trim();\n  if (!q) throw new ArgumentError(`upwork ${label} cannot be empty`);\n  return q;\n}\n// run before the call:\nif (!String(rawQuery ?? '').trim()) throw new Error('Provide a non-empty search query');","typeGuard":"function isNonEmptyQuery(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  rows = await cli.search(query);\n} catch (e) {\n  if (e.name === 'ArgumentError' && String(e.message).includes('cannot be empty')) {\n    console.error('Usage: upwork search <query>');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Validate shell variables are non-empty before interpolating into commands.","Always pass the query positional; check the command's argument order.","Trim and re-prompt for interactive input instead of passing blanks.","Fail fast in wrapper scripts with an explicit empty-argument check."],"tags":["argument-validation","input-validation","upwork","cli"],"backgroundTag":"missing-or-empty-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}