Skip to content

fix(conversations): cascade delete orphaned conversation items#6059

Open
skamenan7 wants to merge 8 commits into
ogx-ai:mainfrom
skamenan7:fix/5906-conversation-cascade-delete
Open

fix(conversations): cascade delete orphaned conversation items#6059
skamenan7 wants to merge 8 commits into
ogx-ai:mainfrom
skamenan7:fix/5906-conversation-cascade-delete

Conversation

@skamenan7

@skamenan7 skamenan7 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes a conversations storage bug where deleting a conversation removed the parent row but left conversation_items behind.

After this change, deleting a conversation also deletes its item rows, and item list/retrieve requests now return 404 once 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 retrieval
  • tests/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 storage
  • tests/integration/conversations/test_openai_conversations.py - add an OpenAI-compatible integration regression test that verifies deleted conversations return 404 for item list and item retrieve

Test Plan

  • uv run pytest tests/unit/conversations/test_conversations.py -x --tb=short -v

  • OGX_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=short

  • uv run mypy src/ogx/core/conversations/conversations.py

skamenan7 added 4 commits June 8, 2026 13:19
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>
@skamenan7 skamenan7 marked this pull request as ready for review June 8, 2026 20:27

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: conversation delete leaves orphaned conversation_items accessible

2 participants