[BUG] Session JSONL files contain corrupt parentUuid references to non-existent UUIDs

Resolved 💬 3 comments Opened Feb 2, 2026 by ArchMeta1868 Closed Feb 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code writes parentUuid values that reference UUIDs that don't exist in the session file. This corrupts the conversation chain at write time, making it impossible to resume the full conversation.

This is different from #22107 and #22030 — those assume the JSONL data is intact but not being read correctly. This bug is about data corruption during writing.

Root Cause

When Claude Code writes messages to the session JSONL file, it sometimes generates parentUuid values pointing to UUIDs that were never written to the file. When resume walks the parent chain backwards, it hits these phantom references and stops, resulting in only a few messages being loaded.

Evidence

In a test session with 4 conversation messages, the chain is broken:

Line 2 (test 1):     parentUuid: null              uuid: "8a5209f6-..."  ✓ Valid root
Line 3 (response):   parentUuid: "8a5209f6-..."    uuid: "e431222a-..."  ✓ Valid chain
Line 5 (test 2):     parentUuid: "632017ae-..."    uuid: "6935cb6f-..."  ✗ BROKEN - "632017ae" doesn't exist!
Line 6 (response):   parentUuid: "6935cb6f-..."    uuid: "3ad73692-..."  ✓ Valid chain

The message "test 2" references parentUuid: "632017ae-e7cf-4430-87ae-13dba44d2ea1" — but this UUID does not exist anywhere in the file. The actual previous message has UUID "e431222a-3ddc-4e4a-8b38-6018dff66107".

Full JSONL excerpt showing the broken chain:

{"parentUuid":null,"type":"user","message":{"role":"user","content":"test 1"},"uuid":"8a5209f6-8a5e-4a14-ad5d-1f22fe71906c","timestamp":"2026-02-02T09:11:37.627Z",...}
{"parentUuid":"8a5209f6-8a5e-4a14-ad5d-1f22fe71906c","type":"assistant","message":{"role":"assistant",...},"uuid":"e431222a-3ddc-4e4a-8b38-6018dff66107","timestamp":"2026-02-02T09:11:41.446Z",...}
{"parentUuid":"632017ae-e7cf-4430-87ae-13dba44d2ea1","type":"user","message":{"role":"user","content":"test 2"},"uuid":"6935cb6f-986a-4474-927d-e4bf36f7e4c0","timestamp":"2026-02-02T09:11:45.365Z",...}

Note: 632017ae-e7cf-4430-87ae-13dba44d2ea1 appears nowhere else in the file. It's a phantom reference.

Impact

  • Severity: Critical — This causes permanent data loss of conversation context
  • After an IDE crash, users cannot resume their work
  • Larger sessions (9MB+, 900+ lines) are affected, losing all but the last few messages
  • sessions-index.json shows messageCount: 2 for a file with 951 lines because it counts the valid chain length

What Should Happen?

When writing a new message to the JSONL file, parentUuid should always reference an existing UUID from a message already in the file (or null for the first message).

Error Messages/Logs

Steps to Reproduce

  1. Start a session and have a conversation
  2. Exit the session
  3. Resume with claude --resume
  4. Observe only 1-2 messages load instead of full history
  5. Examine the JSONL file:

```bash
# Find messages with parentUuid that don't exist
cat session.jsonl | jq -r '.parentUuid' | sort | uniq > parents.txt
cat session.jsonl | jq -r '.uuid' | sort | uniq > uuids.txt
comm -23 parents.txt uuids.txt # Shows phantom UUIDs

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.29

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗