mirror of https://github.com/garrytan/gstack.git
`design variants --count <bad value>` silently produced zero variants
because the generation loop only clamped the upper bound. `--count` arrives
via `parseInt`, which yields NaN for non-numeric input ("abc") and passes
zero/negative values straight through. `Math.min(NaN, 7)` is NaN, so the
`for (i = 0; i < NaN; i++)` loop never ran and the JSON result emitted
`"count": null` — a confusing success-with-nothing for any caller parsing it.
Add an exported `normalizeVariantCount` helper that clamps to the supported
[1, 7] range and falls back to the default of 3 for non-finite input, then
use it where the bare upper-bound cap was. Pure and unit-tested so the
behavior is pinned without an API key.
Fixes #2032
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| auth.test.ts | ||
| daemon-discovery.test.ts | ||
| daemon-tests-fixtures.ts | ||
| daemon.test.ts | ||
| feedback-roundtrip-daemon.test.ts | ||
| feedback-roundtrip.test.ts | ||
| gallery.test.ts | ||
| serve.test.ts | ||
| variants-retry-after.test.ts | ||