{"record":{"id":"b92cf5a07dd435c2","repo":"paperclipai/paperclip","slug":"invalid-label-value","errorCode":null,"errorMessage":"Invalid ${label}: ${value}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/pipelines.ts","lineNumber":713,"sourceCode":"  } catch (error) {\n    throw new Error(`Invalid JSON: ${error instanceof Error ? error.message : String(error)}`);\n  }\n}\n\nfunction asObject(value: unknown): JsonObject {\n  if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n    throw new Error(\"Expected a JSON object.\");\n  }\n  return value as JsonObject;\n}\n\nfunction asOptionalObject(value: unknown): JsonObject | undefined {\n  return value && typeof value === \"object\" && !Array.isArray(value) ? value as JsonObject : undefined;\n}\n\nfunction parsePositiveInt(value: string, label: string): number {\n  const parsed = Number(value);\n  if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`Invalid ${label}: ${value}`);\n  return parsed;\n}\n\nfunction parseCsv(value: string): string[] {\n  return value.split(\",\").map((item) => item.trim()).filter(Boolean);\n}\n\nfunction setIfDefined(target: JsonObject, key: string, value: unknown): void {\n  if (value !== undefined) target[key] = value;\n}\n\nfunction looksLikeUuid(value: string): boolean {\n  return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);\n}\n\nfunction exactlyOneFlag(first: boolean | undefined, second: boolean | undefined, firstName: string, secondName: string): string {\n  if (Boolean(first) === Boolean(second)) throw new Error(`Pass exactly one of ${firstName} or ${secondName}.`);\n  return first ? firstName : secondName;","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/pipelines.ts#L695-L731","documentation":"Thrown by parsePositiveInt() in the pipelines CLI when a numeric flag value cannot be parsed as a positive integer. It is a user-input validation guard used for --expected-version and --lease-seconds options before they are sent to the API. The error interpolates the offending label and raw value so the operator can see which flag was wrong.","triggerScenarios":"Calling `paperclipai pipelines ... --expected-version <v>` or `--lease-seconds <n>` where the value fails `Number.isInteger(parsed) || parsed <= 0`. Concrete producers: `--expected-version 0`, `--lease-seconds -5`, `--expected-version 3.5`, `--lease-seconds abc`, or omitting a value so commander passes an empty string.","commonSituations":"Operators typing a version ordinal that is zero or negative, passing a decimal version like `2.1`, or copy-pasting a value with whitespace/units. Also triggered when a wrapper script passes an unset shell variable that expands to empty.","solutions":["Re-run the command with a positive integer for the named flag (e.g. `--expected-version 3`, `--lease-seconds 60`).","If the value comes from a shell variable, ensure it is set and numeric: `--expected-version \"${EXPECTED_VERSION:?must be set}\"`.","If you intended an unset/optional value, omit the flag entirely instead of passing 0 or empty."],"exampleFix":"// before\npaperclipai pipelines checkout <id> --lease-seconds 0\n// after\npaperclipai pipelines checkout <id> --lease-seconds 60","handlingStrategy":"validation","validationCode":"function positiveInt(v: string, label: string): number {\n  const n = Number(v);\n  if (!Number.isInteger(n) || n <= 0) {\n    throw new Error(`Invalid ${label}: ${v}`);\n  }\n  return n;\n}\n// call before the API: const version = positiveInt(opts.expectedVersion, \"expected version\");","typeGuard":"function isPositiveIntString(v: unknown): v is string {\n  return typeof v === \"string\" && Number.isInteger(Number(v)) && Number(v) > 0;\n}","tryCatchPattern":null,"preventionTips":["Validate numeric CLI args at the commander option level with a custom parser so bad values fail with usage, not at runtime.","When sourcing values from env/shell variables, default them in a single normalized place and assert numeric before passing."],"tags":["cli","validation","integer","pipelines","user-input"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}