SciCatProject / SciCatProject/backend
Dataset.techniques field could have more than one items with duplicated pid
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 37
- Avg merge
- 17h 32m
- Merged PRs (30d)
- 38
Description
Issue Name
Dataset.techniques field could have more than one items with duplicated pid
Summary
When adding a new dataset it is possible to add an array of techniques with the same pid. This is possible because mongodb/mongoose only ensures that the document is unique but not ensures that all the document inside the array has unique pid.
Steps to Reproduce
- Send POST request to /datasets with
techniques : [
{
"pid": "2",
"name": "a"
},
{
"pid": "2",
"name": "a"
}
]
- Send a GET request to get your newly added dataset or check out this dataset from the database you will see the technique array with two elements which has the same pid.
Current Behaviour
Is able to have two or more techniques with the same pid in the array.
Expected Behaviour
Should not be able to add dataset with duplicated pids in technique array. Should return 422.
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.
Research direction
Start at the POST /datasets endpoint and the validation or schema handling for the techniques array, then reproduce the request shown in the issue. Done means datasets containing duplicate technique pids are rejected with a 422 response while valid arrays remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100