Skip to content

fix(session): skip corrupt lines in load_transcript instead of crashing#1744

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8058968e
Mar 17, 2026
Merged

fix(session): skip corrupt lines in load_transcript instead of crashing#1744
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8058968e

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvaged from PR #1193 by @alireza78a.

load_transcript() had no error handling around json.loads(). If the gateway is killed mid-write (OOM, SIGKILL, power loss), the last line of the JSONL transcript file can end up partial/truncated. On the next session load, json.loads raises JSONDecodeError and the entire transcript fails to load — the user sees blank context with no history.

Changes

  • Wrap json.loads(line) in a try/except json.JSONDecodeError block
  • Skip the corrupt line and log a logger.warning with the session ID and truncated line content (first 120 chars) for debugging visibility
  • The rest of the history loads normally

Tests

3 new tests in TestLoadTranscriptCorruptLines:

  • test_corrupt_line_skipped — truncated JSON mid-line is skipped, valid lines before and after load fine
  • test_all_lines_corrupt_returns_empty — file with only corrupt lines returns empty list (no crash)
  • test_valid_transcript_unaffected — normal transcripts still load correctly

All 5231 tests pass.

Closes #1193

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR #1193 by alireza78a.
Closes #1193
@teknium1 teknium1 merged commit 7021910 into main Mar 17, 2026
1 check passed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…ng (NousResearch#1744)

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR NousResearch#1193 by alireza78a.
Closes NousResearch#1193
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…ng (NousResearch#1744)

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR NousResearch#1193 by alireza78a.
Closes NousResearch#1193
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…ng (NousResearch#1744)

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR NousResearch#1193 by alireza78a.
Closes NousResearch#1193
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…ng (NousResearch#1744)

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR NousResearch#1193 by alireza78a.
Closes NousResearch#1193
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…ng (NousResearch#1744)

Wrap json.loads() in load_transcript() with try/except JSONDecodeError
so that partial JSONL lines (from mid-write crashes like OOM/SIGKILL)
are skipped with a warning instead of crashing the entire transcript
load. The rest of the history loads fine.

Adds a logger.warning with the session ID and truncated corrupt line
content for debugging visibility.

Salvaged from PR NousResearch#1193 by alireza78a.
Closes NousResearch#1193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant