fix(member): add existence check before updating member#147
Open
JokMaker wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a pre-update existence check to the member update controller, aligning update behavior with the “Member not found” semantics used elsewhere.
Changes:
- In
updateMember, fetches the member first and returns a 404 if it doesn’t exist. - Updates the PUT controller test to mock
findMemberByIdfor the invalidcodingLevelscenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/controllers/member.controller.ts | Adds an existence check before processing update payload. |
| src/controllers/member.controller.test.ts | Adjusts test setup to account for the new controller dependency on findMemberById. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }); | ||
|
|
||
| it("returns 400 for an invalid codingLevel", async () => { | ||
| vi.mocked(memberService.findMemberById).mockResolvedValue(mockMember); |
Contributor
Author
|
@Nadinefiona @rodriguecyber @Nick-Lemy can you have a look at this PR |
132fb89 to
da971b1
Compare
updateMember was calling the service directly without checking if the member exists, returning a generic Prisma P2025 error message. Added a findMemberById check to return a clean 404 Member not found, matching the pattern in updateEvent, updatePartner, and updateProject.
da971b1 to
e2481bd
Compare
updateMember was calling the service directly without checking if the member exists, returning a generic Prisma P2025 error message. Added a findMemberById check to return a clean 404 Member not found, matching the pattern in updateEvent, updatePartner, and updateProject.
fe79365 to
76f8ecc
Compare
Contributor
Author
|
@Nadinefiona @rodriguecyber @Nick-Lemy can you have a look at this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds an existence check at the top of
updateMemberinsrc/controllers/member.controller.ts. Previously, a missing ID fell through to Prisma's P2025 error → generic"Record not found"404. Now it explicitly returns404 "Member not found", matchingupdateEvent,updatePartner, andupdateProject.Related issue
Closes #
How did you test it?
PUT /api/members/<non-existent-id>now returns404 Member not found. All 17 tests pass.Checklist
npm run build)npm testpassesdocs/openapi.yamlif I changed any routesschema.prisma.env.exampleif needed