A missing Activity, or any integrity error that is not a duplicate, gets the wrong status
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
Research direction
Start with the named handlers: CollectionService.create, ShotService.create, SourceService.create, and DeviceService.create, then compare their integrity error handling with the dataset and collection update handlers. Check Activity lookup in dataset and collection create and update, and read tests/api/v1/test_update_integrity.py for the expected behavior. Done means missing Activities return 404 before writes, only unique violations return 409, other integrity errors are re-raised, and the named test expects 404.
Written by the indexing model from the issue text.
Description
What happens
A request whose activity_id names no Activity fails at the database's foreign key, and the API reports it as something else:
POST /v1/collections/with{"name": "c", "activity_id": 999999}answers 409Collection 'c' already exists in this context.POST /v1/datasets/with{"name": "d", "activity_id": 999999}answers 500.PATCH /v1/datasets/{id}orPATCH /v1/collections/{id}with{"activity_id": 999999}answers 500.
A derived_from entry naming a dataset that does not exist already answers 404 (Dataset 999999 not found). A missing Activity should answer the same way, before anything is written.
Why
CollectionService.create turns every IntegrityError into a ConflictError, so a foreign-key violation reads as a duplicate name. Since #236, the dataset handler and the collection update map only unique violations to 409 and re-raise anything else, so the same request fails there with 500.
Three other create handlers also treat every IntegrityError as a duplicate: ShotService.create, SourceService.create and DeviceService.create. Today only a duplicate reaches them, because they look the device up first, but any constraint added to those tables later would be reported as "already exists".
What to change
- On dataset and collection create and update, look up the Activity named by
activity_idand raiseResourceNotFoundError(404) if it does not exist. - In the collection, shot, source and device create handlers, map only
psycopg.errors.UniqueViolationto 409, and roll back and re-raise anything else, as the dataset and collection update handlers do. test_update_missing_activity_preserves_integrity_errorintests/api/v1/test_update_integrity.pyexpects the 500. Change it to expect 404.
- Dominant language
- Python
- Stars
- 0
- Forks
- 3
- Avg merge
- 23h
- Merged PRs (30d)
- 70
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 ukaea/fds
-
Use registered media types for HDF5 and NetCDF, and stop claiming media_type must be IANA-registeredOpendocumentation metadata
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
Media typeOpen
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
auth
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
fair-compliance metadata
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
fair-compliance metadata
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
Similar issues
-
binding:python bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
The Browser tab fails with a Wayland error when Open Terminal runs from a Wayland desktop sessionOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-webui/open-terminal#210 ·
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agentscope-ai/agentscope#3807 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#150542 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100
triton-inference-server/server#9069 ·
Maintainers usually reply within 1 day