Skip to content

Comments

Fix UnicodeDecodeError in diskcache TAGS_CACHE.get()#4844

Open
314clay wants to merge 1 commit intoAider-AI:mainfrom
314clay:fix/4729-unicode-decode-diskcache
Open

Fix UnicodeDecodeError in diskcache TAGS_CACHE.get()#4844
314clay wants to merge 1 commit intoAider-AI:mainfrom
314clay:fix/4729-unicode-decode-diskcache

Conversation

@314clay
Copy link
Contributor

@314clay 314clay commented Feb 16, 2026

Summary

Fixes #4729

TAGS_CACHE.get() in aider/repomap.py can crash with UnicodeDecodeError (or pickle.UnpicklingError / ValueError) when diskcache encounters corrupted cache entries. The existing tags_cache_error() recovery mechanism only caught SQLITE_ERRORS (sqlite3 and OS errors), missing these deserialization failures.

Changes:

  • aider/repomap.py: Add import pickle and expand the SQLITE_ERRORS tuple to include UnicodeDecodeError, pickle.UnpicklingError, and ValueError — all existing except clauses already catch SQLITE_ERRORS and call tags_cache_error() for cache recreation, so this is a one-line fix
  • tests/basic/test_repomap.py: Add TestTagsCacheErrorRecovery with 4 tests:
    • test_unicode_decode_error_in_cache_get — poisons TAGS_CACHE.get() with UnicodeDecodeError, verifies recovery
    • test_unpickling_error_in_cache_get — same with pickle.UnpicklingError
    • test_value_error_in_cache_get — same with ValueError
    • test_cache_errors_in_sqlite_errors_tuple — verifies all three types are in SQLITE_ERRORS

Test plan

  • pytest tests/basic/test_repomap.py — all 49 tests pass (45 existing + 4 new)

Add UnicodeDecodeError, pickle.UnpicklingError, and ValueError to the
SQLITE_ERRORS tuple so corrupted cache entries trigger cache recreation
via tags_cache_error() instead of crashing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Uncaught UnicodeDecodeError in core.py line 284

3 participants