Bulk upload and record/session create accept future dates; only the Start Session form checks them
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- full-stack
Direzione di ricerca
Start with the existing check in StartSessionForm.tsx (.max(currentDate)), then the upload path: parseDateEntry and the row schema in apps/web/src/utils/upload.ts, and the $DateLike fields in packages/schemas/src/instrument-records/instrument-records.ts. Server-side, follow InstrumentRecordsService.upload into SessionsService.createMany. Done means a shared past-date schema rejects future dates with a 422 that includes the row index, the web upload blocks them with row number and value, and unit and e2e tests cover both.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
The CSV bulk upload accepts a record date in the future, and so does every server path that creates records or sessions. The only future-date check is in the web Start Session form (StartSessionForm.tsx, .max(currentDate) → session.errors.assessmentMustBeInPast). The bulk upload does not use that form, so nothing stops a typo.
Observed
On a production instance (v2.5.2), 17 MOUSE_ORIGIN_FORM records were bulk-uploaded on 2026-06-22. Each record and its RETROSPECTIVE session were dated 2027-06-22: the year was mistyped in the CSV. The data stayed one year in the future for almost five months, until a manual audit found it. It had to be corrected with a direct database update, because PATCH /instrument-records/:id cannot change date and there is no session update endpoint.
Audit of the upload path
No layer checks that the date is not in the future:
| Layer | Location | Check on date |
|---|---|---|
| CSV parsing (web) | apps/web/src/utils/upload.ts parseDateEntry |
only "is a valid date" (new Date(entry)) |
| Row schema (web) | upload.ts, instrumentSchema.extend({ date: z.date(), … }), in both the Zod 3 and Zod 4 branches |
none |
| Request schema (shared) | $UploadInstrumentRecordsData.records[].date = $DateLike (packages/schemas/src/instrument-records/instrument-records.ts) |
none |
| Service (API) | InstrumentRecordsService.upload → SessionsService.createMany |
none |
The single-record and session create paths have the same gap on the server: $CreateInstrumentRecordData.date and $CreateSessionData.date are plain $DateLike. Today the web form protects them, but a direct API client or a script does not get that protection.
Two related weaknesses in the same parser:
parseDateEntryusesnew Date(entry), so the meaning of a value depends on its format. A date-only ISO string is read as UTC midnight, but a value like6/22/2026is read in the browser's local time zone, and6/22/27becomes 2027 without any warning.- The page shows no summary of the date range before the user submits, so a wrong year is easy to miss in a file of hundreds of rows.
Proposal
- Shared: add a schema for a record or session date that must not be in the future, for example
$PastDateLike. Allow a small tolerance (for example the end of the current day in UTC) for clock skew. Use it for$UploadInstrumentRecordsData.records[].date,$CreateInstrumentRecordData.dateand$CreateSessionData.date. The server then rejects the request with a 422 that gives the row index. - Web upload: apply the same limit in the row schema of both Zod branches, and show the row number and the value in the error message. Before submit, show the earliest and the latest date found in the file.
- Do not limit date fields inside an instrument's own data. Some are in the future by design (for example a predicted birth date or an expiry date).
- Optional: accept only ISO
YYYY-MM-DD(or full ISO datetime) in the CSVdatecolumn, so that the parsing does not depend on the browser.
Each change needs a unit test and an e2e test.
- Lingua principale
- TypeScript
- Stelle
- 119
- Fork
- 19
- Merge medio
- 1g 18h
- PR unite (30g)
- 61
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DouglasNeuroInformatics/OpenDataCapture
-
Area: API Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
DouglasNeuroInformatics/OpenDataCapture#1937 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Infrastructure Bug Difficulty: Low Priority: Medium Security
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
DouglasNeuroInformatics/OpenDataCapture#1916 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Infrastructure Chore Difficulty: Low Priority: Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
DouglasNeuroInformatics/OpenDataCapture#1835 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
DouglasNeuroInformatics/OpenDataCapture#1824 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Completing a series instrument logs a TypeError "Cannot read properties of undefined (reading 'kind')"Forse già presa @SAY-5 l’ha presa 3 giorni fa. ApertaArea: Shared Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
DouglasNeuroInformatics/OpenDataCapture#1813 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di DouglasNeuroInformatics/OpenDataCapture
Issue simili
-
infra needs-triage
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 82/100
LucasSantana-Dev/Lucky#3331 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
kOaDT/oss-oopssec-store#381 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nocobase/nocobase#11669 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
iOS: Clear Context (/clear) and model picker fallback use negative agent check instead of isClaudeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno