Skip to content

fix: return 409 when an embedding is used by RAG - #131

Open
Absamad-dew wants to merge 1 commit into
ai-forever:mainfrom
Absamad-dew:codex/fix-embedding-delete-conflict
Open

fix: return 409 when an embedding is used by RAG#131
Absamad-dew wants to merge 1 commit into
ai-forever:mainfrom
Absamad-dew:codex/fix-embedding-delete-conflict

Conversation

@Absamad-dew

Copy link
Copy Markdown

Summary

  • return 409 Conflict before deleting an embedding referenced by a RAG collection
  • preserve the existing 204 No Content path for unreferenced embeddings
  • add repository and route regression coverage for the dependency check and side effects

Rationale

RagCollection.embedding_id uses ON DELETE RESTRICT, so deleting a referenced embedding currently reaches the database and surfaces an unhandled foreign-key error. The explicit dependency check keeps that data-integrity policy, avoids poisoning the SQLAlchemy transaction with an expected constraint failure, and gives the client an actionable response. It does not translate unrelated IntegrityError exceptions into 409 responses.

Validation

  • uv run --frozen ruff check giga_agent/models/rag.py giga_agent/routes/embeddings.py tests/models/test_rag_collections_repository.py tests/routes/test_embeddings_router.py
  • uv run --frozen ruff format --check giga_agent/models/rag.py giga_agent/routes/embeddings.py tests/models/test_rag_collections_repository.py tests/routes/test_embeddings_router.py
  • uv run --frozen pytest tests/routes/test_embeddings_router.py tests/models/test_rag_collections_repository.py (21 passed)

Closes #86

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.

Ошибка удаления модели

1 participant