Skip to content

[Bug] Corrupted persisted session JSON can break session restore on startup #304

@Flamki

Description

@Flamki

Problem

If a persisted session file on disk is malformed (for example, truncated JSON), load_session() can raise a JSON parsing error while restoring sessions.

Why this matters

One bad session file should not impact the whole restore flow. Right now, a corrupted file can interfere with startup/session reload behavior instead of being isolated.

Expected behavior

  • Corrupted session files should be skipped safely.
  • Valid session files should still be restored.
  • We should log a warning so operators can identify and clean up bad files.

Proposed fix

  • Guard JSON reading in the session load path.
  • On read/parse failure, return a safe fallback ([]) and log a warning.
  • Validate payload shape (must be a list) before returning it.

Validation

Add tests for:

  • malformed JSON fallback
  • non-list JSON payload fallback
  • reload path restoring valid files while skipping malformed ones

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions