Repository navigation
Fix startup with malformed persistent history - #1868
Merged
tleonhardt merged 2 commits intoDec 5, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1868 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 23 23
Lines 6777 6777
=======================================
Hits 6761 6761
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
tleonhardt
approved these changes
Dec 5, 2026
tleonhardt
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix, Muneer, and for including a clear reproduction in the issue. I verified that each reported payload starts with empty history and that the rewritten history loads on the next startup. The regression test now checks the empty history directly, and all 28 CI checks passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An unreadable persistent-history payload can still prevent a
Cmdapplication from starting, even though other invalid history files already produce an error message and start with empty history.The missing cases are invalid UTF-8 after LZMA decompression, and JSON values whose shape causes
History.from_json()to raiseTypeErrorrather thanKeyErrororValueError. For example, this public API reproduction fails on current main:The constructor raises
TypeError. Replacingb"[]"withb"\xff"reproduces the uncaughtUnicodeDecodeError;nulland42also fail during JSON restoration.Include those exceptions in the existing recovery handlers. The application then reports the existing diagnostic, starts with empty history, and uses the existing exit handler to rewrite the history file. Valid history loading is unchanged.
The existing bad-JSON test is extended with the four failing payloads and their expected diagnostics. It has four failures and one passing control against original production source, and all five cases pass with the fix.
Local verification on Windows, CPython 3.13:
make test, with one pytest worker: 2,976 passed, 264 platform skips; 92.3% source coverage on Windows.make checkand the strictmake docs-testpass. The docs check used a full Git history, as required by its revision-date plugin.Other platforms and Python versions remain for upstream CI. The local full-suite run used a checkout path without spaces because existing script tests pass some paths without quoting them.
Closes #1867