test_create_is_idempotent_per_name asserts an obsolete create_partition contract (only failure in tests/integration/repos)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- postgresql, python
- Domain
- databases, testing-qa
Research direction
Start with tests/integration/repos/test_partition_repo.py::TestCreateList::test_create_is_idempotent_per_name and compare its assertions with the documented PgPartitionRepository.create_partition contract. Run the provided PostgreSQL-backed tests/integration/repos command, check for other tests with the obsolete assumption, and finish when the duplicate-create test expects PARTITION_EXISTS with status 409 and confirms one row remains.
Written by the indexing model from the issue text.
Description
Summary
tests/integration/repos/test_partition_repo.py::TestCreateList::test_create_is_idempotent_per_name fails against a real Postgres. The test asserts a contract the production code deliberately stopped honouring, so the test is stale rather than the code being broken.
E core.utils.exceptions.ValidationError: PARTITION_EXISTS: Partition 'dup' already exists.
Detail
The test calls create_partition("dup") twice and expects the second call to swallow the conflict:
# The legacy method swallows the conflict and returns the existing row
# rather than raising. Orchestrators rely on this for "ensure exists".
await repo.create_partition("dup")
PgPartitionRepository.create_partition raises PARTITION_EXISTS (409) instead, and its docstring says so explicitly:
Existing partitions are not treated as successful creates. The service layer needs that distinction so it does not update preset/config fields for a partition it did not create.
The raise was introduced in 60b006de ("fix(forward-port): address remaining review feedback"). The test comment was never updated.
The claim that "orchestrators rely on this for ensure-exists" is also no longer true — PartitionService.seed_default_partition, the one ensure-exists caller, guards with partition_exists before creating:
if await self._partition_repo.partition_exists(name="default"):
return
await self._partition_repo.create_partition(name="default", user_id=user_id)
Reproduction
docker run -d --rm --name pg -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root_password \
-e POSTGRES_DB=postgres -p 5433:5432 postgres:16
export POSTGRES_TEST_ADMIN_DSN="postgresql://root:root_password@127.0.0.1:5433/postgres"
uv run pytest tests/integration/repos -q
# 1 failed, 115 passed, 14 skipped, 1 xfailed
Pre-existing on develop; not introduced by any branch in flight. It is currently the only failure in tests/integration/repos, which otherwise passes clean — so it costs the suite its value as a green/red signal.
Suggested direction
Rewrite the test to assert the real contract: a duplicate create_partition raises ValidationError with code PARTITION_EXISTS and status 409, and leaves exactly one row. Drop the stale comment.
Worth a quick check for other tests carrying the same obsolete assumption.
- Dominant language
- Python
- Stars
- 248
- Forks
- 57
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 71
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from linagora/openrag
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
security severity:low
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
severity:medium
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 Under an hour Newbie friendliness 68/100
All issues in linagora/openrag
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100