You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: report unreadable caches from search API routes - #360
Addresses the API error paths reported in #335. With serve --no-convert and an unreadable cache, /api/search and /api/projects currently return HTTP 500 with a raw DatabaseError(...) representation, even though /api/ping already diagnoses the unreadable cache.
Route corruption raised by the search readiness check through the existing unavailable-index diagnostic and HTTP 400 path.
Report an unreadable projects cache as a readable HTTP 400 error, without substituting an empty successful result.
Keep unrelated SQLite errors unchanged. No cache deletion, retry, repair, or extra readiness query is added to a healthy search.
This is scoped to the two backend error responses; it does not change the frontend restart hint discussed in #335.
Validation
New real-loopback HTTP regression cases for both endpoints failed on the base (500 instead of 400), then passed with the fix.
python -m pytest --noconftest -o addopts= test/test_api.py -q: 21 passed, including the existing search no-full-scan test and a new check that unrelated database errors still propagate. Temporary files and HOME were isolated; pytest reported four warnings for optional plugins not installed.
Locked Ruff 0.14.7 check and format-check: passed on both changed files.
Additional synthetic-only acceptance: install, CLI help, file/directory/session-id conversion, HTML in both themes, Markdown/JSON/stdout, date filtering, token statistics, cache/search API, append/watch detection; actual Chromium page/filter/search checks in both themes passed.
Full just ci, upstream shared fixtures, TUI/provider discovery, large real-archive performance and network-dependent timeline behavior were not run. Local acceptance used only newly constructed synthetic records, an isolated HOME/cache and a loopback server; it did not access user archives or execute transcript commands.
Summary by CodeRabbit
Bug Fixes
Search and project requests now return a clear error when the cache database is unreadable.
Search requests handle an unreadable index through the existing unavailable-index error response.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID: ef7fac17-fa24-45d9-9834-6263f09afb44
📥 Commits
Reviewing files that changed from the base of the PR and between 9834d25 and 8a06a9d.
📒 Files selected for processing: 2
claude_code_log/api.py
test/test_api.py
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
📝 Walkthrough
The projects and search API paths now handle recognized corrupt-cache errors. Tests verify sanitized HTTP 400 responses and confirm that other database errors still propagate.
Changes: Corrupt Cache API Handling
Layer / File(s)
Summary
API handling and validation claude_code_log/api.py, test/test_api.py
SearchApi.projects converts recognized corruption errors to an unreadable-cache ValueError and re-raises other database errors. SearchApi.search treats recognized corruption errors from index_ready as an unavailable index. Tests check HTTP 400 responses with sanitized messages and verify that a missing projects table still raises sqlite3.OperationalError.
Unreadable caches on the search and projects endpoints now produce a readable HTTP 400 instead of a raw HTTP 500. No concrete merge-blocking risk remains.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: reporting unreadable cache errors from the search API routes.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
This branch has not been deployed
No deployments
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
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.
Summary
Addresses the API error paths reported in #335. With
serve --no-convertand an unreadable cache,/api/searchand/api/projectscurrently return HTTP 500 with a rawDatabaseError(...)representation, even though/api/pingalready diagnoses the unreadable cache.This is scoped to the two backend error responses; it does not change the frontend restart hint discussed in #335.
Validation
python -m pytest --noconftest -o addopts= test/test_api.py -q: 21 passed, including the existing search no-full-scan test and a new check that unrelated database errors still propagate. Temporary files and HOME were isolated; pytest reported four warnings for optional plugins not installed.Full
just ci, upstream shared fixtures, TUI/provider discovery, large real-archive performance and network-dependent timeline behavior were not run. Local acceptance used only newly constructed synthetic records, an isolated HOME/cache and a loopback server; it did not access user archives or execute transcript commands.Summary by CodeRabbit