{"record":{"id":"781eceabb39effc0","repo":"jackwener/OpenCLI","slug":"number-numraw-is-not-a-positive-integer","errorCode":null,"errorMessage":"number \"${numRaw}\" is not a positive integer","messagePattern":"number \"(.+?)\" is not a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/task-get.js","lineNumber":35,"sourceCode":"  site: SLOCK_SITE,\n  name: 'task-get',\n  access: 'read',\n  description: 'Fetch a task by channel + taskNumber (GET /tasks/channel/:channelId/number/:taskNumber).',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'channel', positional: true, required: true, help: 'channelId UUID or #name' },\n    { name: 'number', positional: true, required: true, help: 'taskNumber (per-channel integer, as shown in \"task #N\")' },\n    { name: 'server', help: 'Override active server' },\n  ],\n  columns: ['id', 'taskNumber', 'title', 'taskStatus', 'assigneeId'],\n  func: async (page, kwargs) => {\n    const channel = String(kwargs.channel ?? '').trim();\n    if (!channel) throw new ArgumentError('channel required');\n    const numRaw = String(kwargs.number ?? '').trim();\n    if (!/^\\d+$/.test(numRaw)) throw new ArgumentError(`number \"${numRaw}\" is not a positive integer`);\n    const number = parsePositiveInteger(numRaw, 'number');\n    await page.goto(SLOCK_HOME_URL);\n    const snippet = `\n      ${authHeadersFragment({ serverScoped: true, serverIdOverride: kwargs.server })}\n      ${channelResolveFragment(channel)}\n      const res = await fetch('${SLOCK_API_BASE}/tasks/channel/' + encodeURIComponent(channelId) + '/number/' + encodeURIComponent(${JSON.stringify(String(number))}), { credentials:'include', headers });\n      if (res.status === 404) return { kind: 'http', status: 404, where: '/tasks/channel/:id/number/:n (task #' + ${JSON.stringify(number)} + ' not found in channel)' };\n      if (!res.ok) return { kind: res.status===401?'auth':'http', status: res.status, where:'/tasks/channel/:id/number/:n' };\n      const data = await res.json().catch(() => ({}));\n      // Single object or {task: ...} wrapped — accept either.\n      const task = data && data.task ? data.task : data;\n      return { kind: 'ok', rows: [task] };\n    `;\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    const rows = dispatchEvaluateResult(result);\n    return rows.map((t) => ({\n      id: t.id ?? '',\n      taskNumber: t.taskNumber ?? number,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/task-get.js#L17-L53","documentation":"The slock task-get CLI command validates the --number argument with a strict /^\\d+$/ digit-only regex before parsing it via parsePositiveInteger. If the value contains any non-digit character (or is empty), it throws an ArgumentError immediately, before any page navigation or network call. This fail-fast check prevents building an invalid API URL.","triggerScenarios":"Running `slock task-get --channel <ch> --number <value>` where value is empty, contains letters, signs, decimals, spaces, or other non-digits, e.g. --number 12a, --number -1, --number 3.5, --number ''.","commonSituations":"Typing a task key like 'TSK-12' instead of the bare number; pasting a value with trailing whitespace or invisible characters; passing a shell variable that is unset/empty; confusion between task id (uuid) and taskNumber (integer).","solutions":["Pass only digits as --number, e.g. --number 42","If you have a task key/uuid, use the command that looks tasks up by id instead of by number","Strip non-digit characters from the input before invoking (e.g. num=${TSK-12//[!0-9]/} in bash)","Verify the variable you interpolate is non-empty: [ -n \"$NUM\" ] || exit 1"],"exampleFix":"// before\nawait cli('slock', 'task-get', '--channel', 'general', '--number', 'TSK-12');\n// after\nawait cli('slock', 'task-get', '--channel', 'general', '--number', '12');","handlingStrategy":"validation","validationCode":"const numRaw = String(number ?? '').trim();\nif (!/^\\d+$/.test(numRaw)) {\n  throw new Error(`--number must be digits-only, got: \"${numRaw}\"`);\n}","typeGuard":"const isPositiveIntString = (v) => typeof v === 'string' && /^\\d+$/.test(v.trim());","tryCatchPattern":null,"preventionTips":["Always pass the bare numeric taskNumber, never a prefixed key like TSK-12","Trim and sanitize shell variables before interpolating into CLI args","Guard for empty/unset variables before invoking the command"],"tags":["argument-validation","cli-input","fail-fast"],"backgroundTag":"invalid-argument-input","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}