Deleting an instrument record leaves an orphaned session, and no endpoint can delete a session
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 53/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- backend-api-design, databases
Research direction
Start with apps/api/src/instrument-records/instrument-records.service.ts and SessionsController to trace record deletion, session references, and the existing session routes. The issue lists three possible approaches but does not choose one; clarify the intended scope and check the relevant tests before making a change. Done means preventing or removing orphaned sessions as agreed, while preserving sessions that still have records.
Written by the indexing model from the issue text.
Description
Problem
Deleting an instrument record leaves its session in the database, and no endpoint can delete a session.
InstrumentRecordsService.deleteById(apps/api/src/instrument-records/instrument-records.service.ts) deletes the record and its files only.SessionsControllerhas onlyPOST /sessionsandGET /sessions.- The only path that deletes sessions is
DELETE /subjects/:id?force=true, which deletes the whole subject.
Every session created by the bulk upload or by a form holds exactly one record, so each record delete leaves an empty session. These sessions:
- count toward
GET /summarycounts.sessionsand its trend, - appear in the session list and the subject's session history,
- cannot be removed by an admin without direct database access.
Observed
On a production instance (v2.5.2), a cleanup of about 26,000 duplicate bulk-uploaded records through DELETE /instrument-records/:id would leave about 26,000 empty sessions. Before any cleanup, that instance already has 79 sessions with no record.
Options
- In
deleteById, also delete the record's session in the same transaction when no other record references it. - Add
DELETE /sessions/:id(@RouteAccess({ action: 'delete', subject: 'Session' })), rejected while the session still has records. - Both.
Option 1 stops new orphans. Option 2 (or a one-off migration) is still necessary to remove the sessions that are already orphaned.
- Dominant language
- TypeScript
- Stars
- 119
- Forks
- 19
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 61
Getting set up
- Ships a Dockerfile or Docker Compose file
- No 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 DouglasNeuroInformatics/OpenDataCapture
-
Area: API Bug Difficulty: Low Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
DouglasNeuroInformatics/OpenDataCapture#1937 ·
Maintainers usually reply within 1 day
-
Area: Infrastructure Bug Difficulty: Low Priority: Medium Security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
DouglasNeuroInformatics/OpenDataCapture#1916 ·
Maintainers usually reply within 1 day
-
Area: Infrastructure Chore Difficulty: Low Priority: Medium
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
DouglasNeuroInformatics/OpenDataCapture#1835 ·
Maintainers usually reply within 1 day
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DouglasNeuroInformatics/OpenDataCapture#1824 · 1 comment ·
Maintainers usually reply within 1 day
-
Completing a series instrument logs a TypeError "Cannot read properties of undefined (reading 'kind')"Possibly taken @SAY-5 claimed this 3 days ago. OpenArea: Shared Bug Difficulty: Low Priority: Low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
DouglasNeuroInformatics/OpenDataCapture#1813 · 1 comment ·
Maintainers usually reply within 1 day
All issues in DouglasNeuroInformatics/OpenDataCapture
Similar issues
-
infra needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 82/100
LucasSantana-Dev/Lucky#3331 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
kOaDT/oss-oopssec-store#381 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nocobase/nocobase#11669 · 1 comment ·
Maintainers usually reply within 1 day
-
iOS: Clear Context (/clear) and model picker fallback use negative agent check instead of isClaudeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day