gemini-cli - 💡(How to fix) Fix Corrupted metadata line can hide the whole session [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#27276Fetched 2026-05-20 03:59:35
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Root Cause

The loader should attempt recovery before giving up. It can use the filename short ID, later $set records, valid message records, or a best-effort reconstructed metadata object. If it still cannot recover, it should quarantine the file instead of letting cleanup delete it. A valid conversation should not be lost because the first line is the only accepted source of identity

Code Example

for await (const line of rl) {
    if (!line.trim()) continue;
    try {
      const record = JSON.parse(line) as unknown;

---

} catch {
    // ignore parse errors on individual lines
  }

---

if (!metadata.sessionId || !metadata.projectHash) {
    return await parseLegacyRecordFallback(filePath, options);
  }

---

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
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?

The JSONL reader ignores parse errors on individual lines. That sounds resilient, but the metadata line is special. If the first metadata line is truncated or malformed, metadata.sessionId and metadata.projectHash may never be set. The loader then falls back to legacy parsing and returns null. All later valid messages are ignored for listing/resume purposes. A single bad metadata line can make a large conversation disappear from the session list.

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

for await (const line of rl) {
   if (!line.trim()) continue;
   try {
     const record = JSON.parse(line) as unknown;

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

  } catch {
    // ignore parse errors on individual lines
  }

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

  if (!metadata.sessionId || !metadata.projectHash) {
    return await parseLegacyRecordFallback(filePath, options);
  }

What did you expect to happen?

The loader should attempt recovery before giving up. It can use the filename short ID, later $set records, valid message records, or a best-effort reconstructed metadata object. If it still cannot recover, it should quarantine the file instead of letting cleanup delete it. A valid conversation should not be lost because the first line is the only accepted source of identity

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 Corrupted metadata line can hide the whole session [1 participants]