Skip to content

Fix filter_regex on Windows (regex compiled as path → broke dol.Jsons)#64

Merged
thorwhalen merged 1 commit into
masterfrom
claude/fix-filter-regex-windows
Jun 23, 2026
Merged

Fix filter_regex on Windows (regex compiled as path → broke dol.Jsons)#64
thorwhalen merged 1 commit into
masterfrom
claude/fix-filter-regex-windows

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

The bug

filter_regex compiled its pattern with safe_compile, which is intended for
file-path templates and re.escapes its input on Windows. That turned a real
regex like (\.json)$ into a literal-string matcher on Windows, so every
regex key-filter silently broke there.

Most visibly, filter_suffixes('.json') backs dol.Jsons (via
@filt_iter.suffixes('.json')): with the pattern escaped, no *.json key matched
the filter, so any write/read raised:

KeyError: 'Key not in store: <key>.json'

This breaks every dol.Jsons-backed store on Windows (surfaced by a downstream
package's Windows CI).

The fix

filter_regex's argument is a regex by contract, so compile it with
re.compile. safe_compile is left untouched and still used for actual path
templates (mk_pattern_from_template_and_format_dict), where its Windows escaping
is correct.

macOS/Linux behavior is unchanged: there safe_compile only ran os.path.normpath
(a no-op for these patterns) before re.compile.

Verification

  • New OS-independent regression test simulating Linux/Darwin/Windows.
  • Full dol/tests suite green (106 passed, 2 skipped); the 2 pre-existing
    doctest failures (double_up_as_factory, invertible_maps) are unrelated and
    also fail on master.
  • End-to-end: a dol.Jsons write+read+list works under a forced
    platform.system()=="Windows" with this fix (fails without it).

https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp

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 thorwhalen merged commit 4bec2c5 into master Jun 23, 2026
10 of 12 checks passed
@thorwhalen thorwhalen deleted the claude/fix-filter-regex-windows branch June 23, 2026 20:57
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant