{{ message }}
fix: Terminate sync immediately when project is deleted - #366
Merged
Conversation
Fixes #188 where sync fails with FOREIGN KEY constraint violations when a project is deleted during sync operations. Changes: - Add SyncFatalError exception to distinguish fatal from recoverable errors - Detect FOREIGN KEY failures in entity_repository.upsert_entity() - Check exception chain in sync_service.sync_file() and re-raise fatal errors - Add repository-level test for invalid project_id handling - Add integration test to verify fatal errors terminate sync immediately Before: Circuit breaker retries each file 3 times, wastes resources After: First FOREIGN KEY error terminates sync immediately with clear message Fatal errors (project deleted, database corrupt) now bypass the circuit breaker and terminate sync immediately, while recoverable file-level errors (bad markdown, parse errors) continue to use circuit breaker as intended. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Contributor
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.


Summary
Fixes #188 where sync fails with FOREIGN KEY constraint violations when a project is deleted during sync operations.
Problem
When a project is deleted mid-sync, every file fails with a FOREIGN KEY constraint error. The circuit breaker treats these as file-level errors and retries each file 3 times, wasting resources before eventually skipping them all.
Solution
Introduced
SyncFatalErrorexception to distinguish between:Changes
SyncFatalErrorexception inservices/exceptions.pyentity_repository.upsert_entity()to detect FOREIGN KEY constraint failures and raiseSyncFatalErrorwith clear messagesync_service.sync_file()to check exception chain forSyncFatalErrorand re-raise immediatelytest_entity_repository_upsert.pytest_sync_service.pyto verify sync terminates immediatelyBehavior
Before:
After:
SyncFatalErroris raised and propagates through exception chainTest Plan
SyncFatalErroris raised with correct message🤖 Generated with Claude Code