google-gemini / google-gemini/gemini-cli
Corrupt agents.json (valid JSON, wrong shape) crashes acknowledgment
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
## Summary
A corrupt `agents.json` (valid JSON, wrong shape) crashes agent acknowledgment with a raw `TypeError` — or worse, silently drops the user's acknowledgments.
Real runs against the actual code with a sandboxed home (`~/.gemini/acknowledgments/agents.json`):
- file contains `null` → `isAcknowledged` THROWS `TypeError: Cannot read properties of null`, and `acknowledge` throws identically
- file contains `[]` → `acknowledge` returns fine but persists the array shape, so the acknowledgment is silently lost on next load
## Root cause
`AcknowledgedAgentsService.load` only guards the read/parse step. `JSON.parse` succeeds on `null`/`42`/`"str"`/`[]`, and the result is assigned to `acknowledgedAgents` without any shape check. Reachable via interrupted save, full disk, cloud sync conflict, or hand edit — the same threat model as #29195.
## Expected
Validate the parsed shape on load (plain object, not array); fall back to `{}` with a logged error like every other load failure already does.
Contributor guide
Research direction
Start by locating AcknowledgedAgentsService.load and reading its existing read, parse, and error-logging path. Exercise loading null, an array, and other valid-but-invalid shapes, then verify that malformed data falls back to an empty object, logs an error, and preserves acknowledgment behavior on the next load.
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
- 74/100