{"record":{"id":"cb9c96fbca631b3e","repo":"junegunn/fzf","slug":"threads-must-be-a-positive-integer","errorCode":null,"errorMessage":"--threads must be a positive integer","messagePattern":"--threads must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":3450,"sourceCode":"\t\t\tif opts.WalkerOpts, err = parseWalkerOpts(str); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--walker-root\":\n\t\t\tif opts.WalkerRoot, err = nextDirs(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--walker-skip\":\n\t\t\tstr, err := nextString(\"directory names to ignore required\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\topts.WalkerSkip = filterNonEmpty(strings.Split(str, \",\"))\n\t\tcase \"--threads\":\n\t\t\tif opts.Threads, err = nextInt(\"number of threads required\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif opts.Threads < 0 {\n\t\t\t\treturn errors.New(\"--threads must be a positive integer\")\n\t\t\t}\n\t\tcase \"--bench\":\n\t\t\tstr, err := nextString(\"duration required (e.g. 3s, 500ms)\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdur, err := time.ParseDuration(str)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.New(\"invalid duration for --bench: \" + str)\n\t\t\t}\n\t\t\topts.Bench = dur\n\t\tcase \"--profile-cpu\":\n\t\t\tif opts.CPUProfile, err = nextString(\"file path required: cpu\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--profile-mem\":\n\t\t\tif opts.MEMProfile, err = nextString(\"file path required: mem\"); err != nil {\n\t\t\t\treturn err","sourceCodeStart":3432,"sourceCodeEnd":3468,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L3432-L3468","documentation":"Thrown when --threads parses to a negative number. Despite the wording 'positive integer', the check is opts.Threads < 0, so 0 is accepted (0 means auto/default thread count) and any negative value is rejected. A non-numeric value fails earlier in nextInt with 'number of threads required'.","triggerScenarios":"`--threads -4`, or `--threads \"$N\"` where N underflows to negative in shell arithmetic.","commonSituations":"Computing thread counts from CPU/2 style expressions on single-CPU containers producing 0 or negative results (0 passes, negatives do not); attempting -1 as a sentinel for 'automatic' — use 0 instead.","solutions":["Use 0 for automatic thread count, or a positive integer","Clamp computed values: [ \"$N\" -lt 0 ] && N=0","If you wanted 'auto', just omit --threads entirely"],"exampleFix":"# before\nfzf --threads \"$(($(nproc)/2-2))\"\n# after\nN=$(($(nproc)/2-2)); [ \"$N\" -lt 0 ] && N=0\nfzf --threads \"$N\"","handlingStrategy":"validation","validationCode":"# bash: 0 = auto, negatives rejected\nN=\"${THREADS:-0}\"\n[[ \"$N\" =~ ^[0-9]+$ ]] || { echo \"--threads must be numeric\" >&2; exit 1; }\nfzf --threads \"$N\"","typeGuard":"threads_ok() { [[ \"$1\" =~ ^[0-9]+$ ]]; }","tryCatchPattern":null,"preventionTips":["Use 0 (or omit --threads) for automatic sizing","Clamp CPU-count arithmetic to a 0 minimum in container/CI scripts"],"tags":["fzf","go","cli","performance","threads","validation"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}