gemini-cli - 💡(How to fix) Fix File recreation drops the metadata line [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#27279Fetched 2026-05-20 03:59:31
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Code Example

private appendRecord(record: unknown): void {
    if (!this.conversationFile) return;
    try {
      const line = JSON.stringify(record) + '\n';
      fs.mkdirSync(path.dirname(this.conversationFile), { recursive: true });
      fs.appendFileSync(this.conversationFile, line);

---

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
About Gemini CLI│                                                                                                                                                                                                                                                                                 │
CLI Version                                                                                    0.42.0Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
Model                                                                                          Auto (Gemini 3)Sandbox                                                                                        no sandbox                                                                                                                                                                       │
OS                                                                                             linux                                                                                                                                                                            │
Auth Method                                                                                    Signed in with GoogleTier                                                                                           Gemini Code Assist in Google One AI Pro│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

appendRecord() only checks whether this.conversationFile is non-null. It does not check whether the file still exists. If cleanup or a manual action deletes the file while the process is still alive, the next appendFileSync() recreates it. But it recreates it with only the record being appended, not the initial metadata. The resulting file can contain messages but no metadata line. Later, loadConversationRecord() cannot load it as a valid session.

packages/core/src/services/chatRecordingService.ts:450

  private appendRecord(record: unknown): void {
    if (!this.conversationFile) return;
    try {
      const line = JSON.stringify(record) + '\n';
      fs.mkdirSync(path.dirname(this.conversationFile), { recursive: true });
      fs.appendFileSync(this.conversationFile, line);

What did you expect to happen?

Before appending, check whether the file exists and still has metadata. If it was deleted, write cachedConversation metadata first. Then append the message. A recorder with valid in-memory session metadata should not create a zombie file that list/resume can never parse.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
│ About Gemini CLI                                                                                                                                                                                                                                                                │
│                                                                                                                                                                                                                                                                                 │
│ CLI Version                                                                                    0.42.0                                                                                                                                                                           │
│ Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
│ Model                                                                                          Auto (Gemini 3)                                                                                                                                                                  │
│ Sandbox                                                                                        no sandbox                                                                                                                                                                       │
│ OS                                                                                             linux                                                                                                                                                                            │
│ Auth Method                                                                                    Signed in with Google                                                                                                                            │
│ Tier                                                                                           Gemini Code Assist in Google One AI Pro                                                                                                                                          │
│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

Signed in with Google

Anything else we need to know?

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix File recreation drops the metadata line [1 participants]