fix: mine --dry-run TypeError on files with room=None (#586)#687
Merged
bensig merged 2 commits intoMemPalace:developfrom Apr 12, 2026
Merged
fix: mine --dry-run TypeError on files with room=None (#586)#687bensig merged 2 commits intoMemPalace:developfrom
bensig merged 2 commits intoMemPalace:developfrom
Conversation
process_file() returned (0, None) for already-mined, unreadable, and too-short files. In --dry-run mode the caller always enters the room_counts branch, so None ended up as a dict key and crashed the summary printer with "unsupported format string passed to NoneType.__format__". Returning "general" instead of None makes the function contract explicit: it always yields (int, str). This matches the consensus fix discussed in the issue thread.
bensig
approved these changes
Apr 12, 2026
Collaborator
bensig
left a comment
There was a problem hiding this comment.
Code review + security audit clean.
jphein
added a commit
to jphein/mempalace
that referenced
this pull request
Apr 12, 2026
Upstream merged MemPalace#682-684 (our splits), MemPalace#687 (dry-run None room), MemPalace#695/MemPalace#708 (convo_miner full response), MemPalace#732 (0-chunk re-processing), plus VitePress docs site. Conflicts: - config.py: take upstream's [^\W_] regex (our MemPalace#683 merged version) - miner.py: integrate upstream's early-return for tiny files, dedupe dry-run read path - test_miner.py: keep our detect_room tests + upstream's dry-run test - CONTRIBUTING.md: take upstream's org URL update Co-Authored-By: Claude Opus 4.6 <[email protected]>
gnusam
pushed a commit
to gnusam/mempalace-pgsql
that referenced
this pull request
Apr 25, 2026
Port of upstream 091c2fe (PR MemPalace#687, fixes MemPalace#586). The four early-exit paths in process_file() previously returned (0, None). In dry-run mode the caller always enters the room_counts branch, so None landed as a dict key and crashed the summary printer with "unsupported format string passed to NoneType.__format__". Returning "general" makes the function contract explicit: it always yields (int, str). Matches the consensus fix from the upstream issue thread. Updated the existing test_process_file_skips_machine_generated_long_lines assertion accordingly — its previous `assert room is None` was codifying the bug. Upstream: MemPalace@091c2fe Co-authored-by: Mikhail Valentsev <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Closes #586.
mempalace mine --dry-runcrashes with a TypeError in the summary printer whenprocess_file()returns(0, None)for unreadable or too-short files. In real mine mode thedrawers == 0 and not dry_runguard skips these entries before they reachroom_counts, but in dry-run mode the guard does not fire andNoneends up as a dict key. The f-string format{room:20}then raisesTypeError: unsupported format string passed to NoneType.__format__.Fix (2 files, +31/-3):
mempalace/miner.py:return 0, Nonepaths inprocess_file()(already-mined, OSError, below MIN_CHUNK_SIZE) now returnreturn 0, "general"instead. This makes the function contract explicit -- it always returns(int, str).tests/test_miner.py:test_mine_dry_run_with_tiny_file_no_crash-- creates a project with one normal file and one below MIN_CHUNK_SIZE, runsmine()withdry_run=True, verifies no crash.Matches the Option 2 consensus from the issue thread (normalize at the source rather than patching the caller).