Fix filter_regex on Windows (regex compiled as path → broke dol.Jsons)#64
Merged
Merged
Conversation
filter_regex compiled its pattern with safe_compile, which is meant for file-path
templates and re.escape's its input on Windows. That turned a real regex like
(\.json)$ into a literal-string matcher, so EVERY regex key-filter was broken on
Windows -- most visibly filter_suffixes('.json'), which backs dol.Jsons: no *.json
key matched, and any write/read raised `KeyError: 'Key not in store: <key>.json'`.
Use re.compile (filter_regex's argument is a regex, by contract). safe_compile is
unchanged and still used for actual path templates (mk_pattern_from_template...),
where its Windows escaping is correct. Behavior on macOS/Linux is unchanged
(safe_compile's normpath was a no-op for these patterns).
Adds an OS-independent regression test (simulates Linux/Darwin/Windows).
Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
thorwhalen
added a commit
to thorwhalen/ek
that referenced
this pull request
Jun 23, 2026
…diagnostic
Root cause of the Windows persistence failures was a dol bug: filter_regex
compiled regexes with the path-oriented safe_compile, which re.escape's on
Windows, so filter_suffixes('.json') (behind dol.Jsons) matched nothing and every
store write raised KeyError: 'Key not in store: <key>.json'. Fixed upstream in
dol 0.3.45 (i2mint/dol#64); pin it here. Reverts the temporary --tb diagnostic.
Closes #11.
Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
thorwhalen
added a commit
to thorwhalen/ek
that referenced
this pull request
Jun 23, 2026
Every dol.Jsons-backed persistence test failed on Windows with
KeyError: 'Key not in store: <key>.json'. Root cause was a dol bug: filter_regex
compiled regexes with the path-oriented safe_compile (re.escape's on Windows),
so filter_suffixes('.json') behind dol.Jsons matched nothing. Fixed upstream in
dol 0.3.45 (i2mint/dol#64); this pins dol>=0.3.45 and reverts the diagnostic.
ek Windows Tests CI now passes (verified on this PR). Closes #11.
https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
thorwhalen
added a commit
that referenced
this pull request
Jun 24, 2026
dol Windows CI: 28 failures -> 0 (Linux/macOS already green). Finishes the regex/path conflation cleanup (safe_compile -> re.compile; escape template literals), replaces POSIX-only os.getuid with getpass.getuser, fixes empty-prefix-> bare-separator (\C:\Users\... OSError on Windows) and a hardcoded "/" in subfolder_stores, and makes the platform-fragile doctests/tests OS-independent. Builds on #64. https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
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.
The bug
filter_regexcompiled its pattern withsafe_compile, which is intended forfile-path templates and
re.escapes its input on Windows. That turned a realregex like
(\.json)$into a literal-string matcher on Windows, so everyregex key-filter silently broke there.
Most visibly,
filter_suffixes('.json')backsdol.Jsons(via@filt_iter.suffixes('.json')): with the pattern escaped, no*.jsonkey matchedthe filter, so any write/read raised:
This breaks every
dol.Jsons-backed store on Windows (surfaced by a downstreampackage's Windows CI).
The fix
filter_regex's argument is a regex by contract, so compile it withre.compile.safe_compileis left untouched and still used for actual pathtemplates (
mk_pattern_from_template_and_format_dict), where its Windows escapingis correct.
macOS/Linux behavior is unchanged: there
safe_compileonly ranos.path.normpath(a no-op for these patterns) before
re.compile.Verification
dol/testssuite green (106 passed, 2 skipped); the 2 pre-existingdoctest failures (
double_up_as_factory,invertible_maps) are unrelated andalso fail on
master.dol.Jsonswrite+read+list works under a forcedplatform.system()=="Windows"with this fix (fails without it).https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp