fix(conversations): cascade delete orphaned conversation items#6059
Open
skamenan7 wants to merge 8 commits into
Open
fix(conversations): cascade delete orphaned conversation items#6059skamenan7 wants to merge 8 commits into
skamenan7 wants to merge 8 commits into
Conversation
Delete conversation_items rows before removing the parent conversation and reject item access once the conversation is gone. This adds unit and integration coverage for the deleted-conversation item access regression. Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
Wrap conversation item and parent-row deletes in a single SQL store transaction so a failed parent delete no longer leaves the conversation half-deleted. Add a regression test that injects a parent delete failure and proves child rows are rolled back with it. Signed-off-by: Sumanth Kamenani <skamenan@redhat.com>
…on-cascade-delete
franciscojavierarceo
approved these changes
Jun 8, 2026
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.
What does this PR do?
Fixes a conversations storage bug where deleting a conversation removed the parent row but left
conversation_itemsbehind.After this change, deleting a conversation also deletes its item rows, and item list/retrieve requests now return
404once the parent conversation is gone.Closes #6058
Part of #5906.
src/ogx/core/conversations/conversations.py- cascade-delete conversation items before deleting the parent conversation and validate the parent conversation before item retrievaltests/unit/conversations/test_conversations.py- add a regression test that verifies deleted conversations cannot list or retrieve orphaned items and that item rows are removed from storagetests/integration/conversations/test_openai_conversations.py- add an OpenAI-compatible integration regression test that verifies deleted conversations return404for item list and item retrieveTest Plan
uv run pytest tests/unit/conversations/test_conversations.py -x --tb=short -vOGX_TEST_FORCE_SERVER_RESTART=1 OLLAMA_URL=http://localhost:11434/v1 uv run pytest -s -v tests/integration/conversations/test_openai_conversations.py --stack-config=server:starter --setup=ollama -x --tb=shortuv run mypy src/ogx/core/conversations/conversations.py