google-gemini / google-gemini/gemini-cli
Corrupt-shaped checkpoint crashes resume: non-array history passes through loadCheckpoint and throws TypeError
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
## Summary
A checkpoint file with valid JSON but a non-array `history` (`{"history": null}`, `{"history": 123}` — from a crash mid-save, a full disk, or a hand edit) passes straight through `loadCheckpoint` and crashes `/resume resume ` with a raw `TypeError` (`null.length` / `number.slice is not a function`).
Verified: `loadCheckpoint` returns `{"history": null}` verbatim today — the object branch only checks that the `history` key *exists*, never that it is an array. The existing test suite covers only invalid JSON (`logger.test.ts`), not wrong-shape JSON.
## Expected
`loadCheckpoint` guarantees its contract: a non-array `history` degrades to an empty checkpoint (with the usual corrupt-file warning), so resume reports "no saved checkpoint" instead of throwing. Same treatment the loader already gives unparseable files.
Contributor guide
Research direction
Start with the loadCheckpoint implementation and the existing logger.test.ts tests, then trace how /resume resume handles the returned checkpoint. Exercise valid JSON with null and numeric history values, and verify that malformed shapes produce the usual corrupt-file warning and an empty checkpoint so resume reports no saved checkpoint instead of throwing.
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
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100