fix: use open_in_memory() for DB init fallback to avoid PermissionDenied panic#646
Open
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
Open
fix: use open_in_memory() for DB init fallback to avoid PermissionDenied panic#646txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
txf0096 wants to merge 1 commit intogit-ai-project:mainfrom
Conversation
…ied panic When DB initialization fails, the fallback path used std::env::temp_dir() to create a dummy SQLite connection. On systems where /tmp is noexec or permission-restricted, Connection::open(&temp_path).expect(...) panics. Replace with Connection::open_in_memory() which: - Never touches the filesystem, so no permission issues - Produces the same behavior (all SQL fails, no schema initialized) - Gives each process its own independent connection instead of contending on a shared fixed-path file Fixes git-ai-project#645
|
No AI authorship found for these commits. Please install git-ai to start tracking AI generated code in your commits. |
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.
Problem
On systems where
/tmpis permission-restricted,git-ai checkpointpanics:Backtrace:
Root Cause
When
InternalDatabase::new()fails (e.g. due toSQLITE_BUSYfrom concurrent processes), bothglobal()functions fall back to a dummy connection viastd::env::temp_dir(). On systems where/tmpisnoexecor permission-restricted,Connection::open(&temp_path).expect(...)panics — turning a graceful degradation into a crash.Additionally, the fixed path
git-ai-db-failedis shared across all processes — if multiple processes hit the fallback simultaneously, they contend on the same file, potentially causing the same lock error again.The comment already describes the intent:
Fix
Replace the fallback with an in-memory connection in both
src/authorship/internal_db.rsandsrc/metrics/db.rs:open_in_memory()matches the original intent exactly — all SQL operations still fail (no schema initialized), the program continues without panic, no filesystem dependency, and each process gets its own independent connection.Impact
git-ai statsis not affected (reads from git notes, notinternal_db)git-ai search,git-ai prompts,git-ai show-prompt,git-ai share— return errors or empty results (same as before, just without the panic)Fixes #645