gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

bug(core): checkpoint names are mangled when the edited file name contains .json

Open ArnabOPP opened this issue 1 week ago • 3 comments

What happened?

Checkpoint names are mangled when the edited file's name contains .json (for example package.json or tsconfig.json).

In packages/core/src/utils/checkpointUtils.ts, processRestorableToolCalls and getCheckpointInfoList both derive the checkpoint name with String.replace('.json', ''). That removes the first .json, not the extension. Checkpoint file names embed the edited file's basename (<timestamp>-<basename>-<toolName>.json), so:

  • written file: 2026-11-22T12-23-32_834Z-package.json-replace.json
  • name returned in toolCallToCheckpointMap and by getCheckpointInfoList: 2026-11-22T12-23-32_834Z-package-replace.json

/restore (ACP and a2a-server) appends .json to the name it is given and reads that file, so restoring by the reported name fails with File not found.

What did you expect to happen?

The reported checkpoint name should be the file name minus only the trailing .json, so it points back at the file that was written.

Client information

Reproduced on current main with a unit-level reproduction (no live session needed): call processRestorableToolCalls with args: { file_path: 'src/package.json' } and compare toolCallToCheckpointMap.get(callId) + '.json' against the key in checkpointsToWrite. They differ.

Login information

Not applicable.

Anything else we need to know?

The fix is a one-line change in each place (/\.json$/ instead of '.json') plus regression tests. I have it ready and will open a PR referencing this issue.

ArnabOPP avatar Nov 22 '26 12:11 ArnabOPP

There is a problem with the Gemini CLI issue triaging. Please check the action logs for details.

gemini-cli[bot] avatar Nov 22 '26 12:11 gemini-cli[bot]

I have a small fix with regression tests ready in #30404 (it also addresses the Gemini Code Assist suggestion) and would like to work on this. Could a maintainer triage this issue and add help wanted if it's appropriate for community contribution? Thanks!

ArnabOPP avatar Nov 22 '26 13:11 ArnabOPP

Friendly note: PR #30404 fixes this and passes CI, but the bot flagged it on Nov 30 because this issue has no help wanted label, so it will auto-close around Dec 7. Could a maintainer triage this one? If it's a good fit, a help wanted label would let the PR proceed to review. If it isn't wanted, no problem — just let me know. Thanks!

ArnabOPP avatar Nov 30 '26 22:11 ArnabOPP