Repository navigation
Conversation
WalEntry.from_dict only checked that key and value were present, not
that they were strings. A hand-edited or corrupted log line such as
{"op": "set", "key": null, "value": "d"} was replayed into the
in-memory dict as a non-string key, which the rest of the engine
never expects.
Raise TypeError for a non-string key or value so replay() treats the
line as corrupt, warns, and truncates the log to the last good entry,
the same as it already does for other malformed records.
Closes danieldeer#322
PhaeezAli
marked this pull request as ready for review
October 17, 2026 19:21
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.
Description
WalEntry.from_dictchecked thatkeyandvaluewere present but not that they were strings. A hand-edited or corrupted log line such as{"op": "set", "key": null, "value": "d"}was replayed into the in-memory dict as a non-string key, which the engine never expects.This raises
TypeErrorfor a non-string key or value, soreplay()handles the line the same way it already handles other malformed records: it logs a warning and truncates the log to the last good entry.The duplicate-field case in the issue is standard JSON last-value-wins and is left unchanged.
Closes #322
Type of Change
Key Changes
from_dictraisesTypeErrorwhenkeyis not astr, or whenvalueis not astrforsetentries.Raisessection updated to match.test_replay_recovers_from_malformed_entry: null key, integer key, list value.Validation
uv run pytest -q→ 187 passeduv run ruff check .anduv run ruff format --check .→ cleanuv run ty check→ cleanuv run --group docs scripts/docs-reference.py --check→ up to datemainwithout thewal.pychange and pass with it.Checklist
uv run ruff check .anduv run ruff format --check ., or this PR does not change Python.Note
AI tooling has been used for: explaining the existing code path, reviewing my diff, and running the check commands. The fix and tests were written and validated by me.
Assisted by: GPTgo