RealDevSquad / RealDevSquad/website-backend
Inconsistent User ID Handling in User Data Fetching Functions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
Issue Description
Inconsistent handling of user ID in user data fetching functions
Expected Behavior
All user data fetching functions should consistently handle the user ID by overriding any existing id field in the user data with the document ID.
Current Behavior
Currently, five functions that fetch user data (fetchUser, fetchUserByIds, fetchPaginatedUsers, getDiscordUsers, and fetchAllUsers) handle the user ID inconsistently. Some may include both the document ID and a potentially conflicting id field from the user data.
Screenshots
N/A
Reproducibility
- This issue is reproducible
- This issue is not reproducible
Steps to Reproduce
- Examine the following functions in
models/users.js:fetchUserfetchUserByIdsfetchPaginatedUsersgetDiscordUsersfetchAllUsers
- Observe how each function handles the user ID when constructing the returned user object.
Severity/Priority
- Critical
- High
- Medium
- Low
Additional Information
The issue can be resolved by ensuring that in all five functions, the document ID is assigned to the id field after spreading the user data. For example:
return {
...userData,
id: documentId,
};
This approach will ensure that the document ID always overrides any existing id field in the user data.
Checklist
- I have read and followed the project's code of conduct.
- I have searched for similar issues before creating this one.
- I have provided all the necessary information to understand and reproduce the issue.
- I am willing to contribute to the resolution of this issue.
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
Open models/users.js and inspect fetchUser, fetchUserByIds, fetchPaginatedUsers, getDiscordUsers, and fetchAllUsers, focusing on how each returned user object handles its ID. Confirm that every function uses the document ID for the id field after incorporating the user data, then verify the affected user-fetching behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100