Skip to content

fix(cache): discard unusable interpreter cache entries - #141

Merged
gaborbernat merged 4 commits into
tox-dev:mainfrom
darrenhuai:fix/cache-entry-wrong-shape
Oct 10, 2026
Merged

gaborbernat merged 4 commits into
tox-dev:mainfrom
darrenhuai:fix/cache-entry-wrong-shape

Conversation

@darrenhuai

@darrenhuai darrenhuai commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Valid JSON cache files can contain a top-level list, string, number or boolean. Missing or invalid system_executable fields also interrupt interpreter discovery.

Discard those entries and query the interpreter again. Require any non-null system_executable to name a regular file, and treat filesystem lookup errors as stale cache entries.

darrenhuai and others added 3 commits October 8, 2026 23:12
DiskCache.read() already drops a py_info cache file that fails to parse,
but valid JSON of the wrong shape got through. A list, string, number or
boolean at the top level reached _read_cache_entry, whose data.get()
raised AttributeError. A content mapping with no system_executable did
the same, and a non-path one (an int, a list) made Path() raise
TypeError. Nothing above caught either, so a single damaged file under
the cache failed every interpreter lookup that hit it. virtualenv, for
one, stops creating environments until someone deletes the file.

Treat any of these the way a file that fails to parse is treated: remove
it and query the interpreter again. That matches what
_load_cached_py_info already did for a bad version_info.
Cached directories and empty paths interrupt host resolution. Treat them
and filesystem lookup errors as stale entries, then query the interpreter
again. Verify cache recovery through the public API with real files.
@gaborbernat gaborbernat added the bug Something isn't working label Oct 10, 2026
@gaborbernat gaborbernat changed the title 🐛 fix(cache): drop a cache entry of the wrong shape instead of crashing fix(cache): discard unusable interpreter cache entries Oct 10, 2026

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat
gaborbernat enabled auto-merge (squash) October 10, 2026 00:52
@gaborbernat
gaborbernat merged commit eb1eab7 into tox-dev:main Oct 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants