fix: delete orphaned DB records when deleting a thread#2803
Open
farukonfly wants to merge 3 commits into
Open
Conversation
f500c3b to
889c7a8
Compare
- Add delete_by_thread() method to RunStore base class
- Implement delete_by_thread() in MemoryRunStore (in-memory)
- Implement delete_by_thread() in RunRepository (SQLAlchemy) with SQLite/PostgreSQL compatibility
- Implement delete_by_thread() in FeedbackRepository (SQLAlchemy) with SQLite/PostgreSQL compatibility
- Update DELETE /{thread_id} endpoint to clean up run and feedback records
- Use SELECT COUNT + DELETE pattern instead of result.rowcount for cross-database compatibility
889c7a8 to
794442b
Compare
- TestMemoryRunStoreDeleteByThread: 3 tests for in-memory RunStore
- TestRunRepositoryDeleteByThread: 4 parametrized tests (SQLite + PG)
- TestFeedbackRepositoryDeleteByThread: 4 parametrized tests (SQLite + PG)
- 5 router-level tests verifying DELETE /api/threads/{id} calls
delete_by_thread on run_store, event_store, and feedback_repo
PG tests gate on PG_TEST_URL env var; skip automatically when absent.
794442b to
e043bea
Compare
Collaborator
|
@farukonfly thanks for your contribution. Please click the CLA button to sign the CLA before we review your patch. |
Author
I have already signed the CLA |
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.
fix: delete orphaned DB records when deleting a thread
Problem
DELETE /api/threads/{id}cleaned up filesystem data but left orphaned rows in the database — runs, run events, and feedback records remained after the thread was deleted.Changes
routers/threads.py: after filesystem/checkpoint/thread-meta cleanup, also calldelete_by_threadonrun_store,run_event_store, andfeedback_repo(all best-effort, errors are logged and swallowed)persistence/run/sql.py: addRunRepository.delete_by_threadpersistence/feedback/sql.py: addFeedbackRepository.delete_by_threadSELECT COUNT+DELETEinstead ofrowcountto work reliably on both SQLite and PostgreSQLTests
TestMemoryRunStoreDeleteByThread— 3 unit tests for in-memory storeTestRunRepositoryDeleteByThread— 4 parametrized tests (SQLite + PostgreSQL)TestFeedbackRepositoryDeleteByThread— 4 parametrized tests (SQLite + PostgreSQL)PostgreSQL tests skip automatically when
PG_TEST_URLis not set.