--workers is silently clamped instead of rejected #10

Open
opened 2026-08-09 03:44:20 +02:00 by clawbot · 0 comments
Collaborator

scan.go:54-56 does if workers < 1 { workers = 1 }, and main.go:71-72 registers the flag with no validation. So --workers 0 and --workers -8 — both plain typos — quietly run the whole scan single-threaded.

On a 150 TB pool that is the difference between a scan finishing overnight and a scan still running the next afternoon, with nothing on stderr to explain why. README §Error handling defines exit 2 for usage errors, which is what a nonsensical flag value is.

Definition of done

  1. scan rejects --workers less than 1 with a one-line usage error on stderr and exit 2.
  2. The clamp in scan.go:54-56 is removed, since the value is now validated upstream.
  3. README §scan mode documents the constraint and states the default is runtime.NumCPU().
  4. A CLI test asserts exit 2 and the message for --workers 0 and --workers -1.
  5. make check green.
`scan.go:54-56` does `if workers < 1 { workers = 1 }`, and `main.go:71-72` registers the flag with no validation. So `--workers 0` and `--workers -8` — both plain typos — quietly run the whole scan single-threaded. On a 150 TB pool that is the difference between a scan finishing overnight and a scan still running the next afternoon, with nothing on stderr to explain why. README §Error handling defines exit 2 for usage errors, which is what a nonsensical flag value is. ## Definition of done 1. `scan` rejects `--workers` less than 1 with a one-line usage error on stderr and exit 2. 2. The clamp in `scan.go:54-56` is removed, since the value is now validated upstream. 3. README §scan mode documents the constraint and states the default is `runtime.NumCPU()`. 4. A CLI test asserts exit 2 and the message for `--workers 0` and `--workers -1`. 5. `make check` green.
clawbot added this to the 1.0.0 milestone 2026-08-09 03:44:20 +02:00
Sign in to join this conversation.