Skip to content

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

Closed as duplicate

Description

@ArchMeta1868

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:
    # 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

Activity

  1. github-actions commented on Feb 2, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] Conversation chain breaks mid-session - earlier messages lost on resume #21617
    2. [BUG] Assistant text messages not written to transcript - only thinking blocks persist #21751
    3. [BUG] saved_hook_context entries written with duplicate UUIDs, corrupting session graph and breaking resume #22178

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. added
    duplicateThis issue or pull request already exists
    and removed
    bugSomething isn't working
    has reproHas detailed reproduction steps
    platform:macosIssue specifically occurs on macOS
    on Feb 6, 2026
  3. github-actions commented on Feb 6, 2026

    @github-actions

    This issue has been automatically closed as a duplicate of #21617.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

  4. github-actions commented on Feb 14, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  5. locked as resolved and limited conversation to collaborators on Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions