gstack-timeline-read accepts malformed --limit values
- Dominant language
- TypeScript
- Stars
- 133k
- Forks
- 19.9k
- Avg merge
- 18h 46m
- Merged PRs (30d)
- 26
Description
## Observed problem
`gstack-timeline-read --limit` accepts malformed values instead of rejecting them. On current upstream `main` (`cf50443b`), `--limit 1abc` is parsed as `1`, and `--limit nope` silently falls back to the default `20`.
## Current behavior on upstream main
Repro with a temporary `GSTACK_HOME` containing three timeline events:
```sh
./bin/gstack-timeline-read --limit 1abc
./bin/gstack-timeline-read --limit nope
./bin/gstack-timeline-read --limit 1
```
Observed:
- `--limit 1abc` exits successfully and shows one recent event, same as `--limit 1`.
- `--limit nope` exits successfully and shows all three events via the default limit.
The parser in `bin/gstack-timeline-read` uses `Number.parseInt(limitRaw, 10)`, so trailing garbage is accepted.
## Expected behavior
`--limit` should require a positive integer token. Malformed, zero, negative, or decimal values should fail with a clear error instead of changing timeline output silently.
## Duplicate searches performed
Searched issues and PRs for:
- `"gstack-timeline-read" "--limit"`
- `"timeline" "malformed" limit`
- `"timeline" "parseInt"`
- `"Number.parseInt(limitRaw"`
- `"1abc"` and `"malformed --limit"`
- open PR bodies touching `bin/gstack-timeline-read`
The only timeline-read match was the already-landed branch quoting fix (#1634/#1635). The malformed-limit match was eval-list-specific (#1683/#1684) and does not touch timeline-read.
## Candidate fix shape
Parse `GSTACK_TIMELINE_LIMIT` with a strict positive-integer regex before converting to `Number`, emit a clear error for invalid values, and add focused `test/timeline.test.ts` coverage for malformed `--limit` values.
Contributor guide
Research direction
Start in bin/gstack-timeline-read, where --limit is parsed with Number.parseInt, and review the focused coverage in test/timeline.test.ts. Reproduce the malformed, zero, negative, and decimal cases, then ensure invalid values produce a clear failure while valid positive integers retain their expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100