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
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
Proposed fix
[]) and log a warning.Validation
Add tests for: