Skip to content

fix(member): add existence check before updating member#147

Open
JokMaker wants to merge 4 commits into
Open-Source-Kigali:devfrom
JokMaker:fix/update-member-existence-check
Open

fix(member): add existence check before updating member#147
JokMaker wants to merge 4 commits into
Open-Source-Kigali:devfrom
JokMaker:fix/update-member-existence-check

Conversation

@JokMaker
Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an existence check at the top of updateMember in src/controllers/member.controller.ts. Previously, a missing ID fell through to Prisma's P2025 error → generic "Record not found" 404. Now it explicitly returns 404 "Member not found", matching updateEvent, updatePartner, and updateProject.

Related issue

Closes #

How did you test it?

PUT /api/members/<non-existent-id> now returns 404 Member not found. All 17 tests pass.

Checklist

  • My code builds (npm run build)
  • I added or updated tests and npm test passes
  • I updated docs/openapi.yaml if I changed any routes
  • I added a Prisma migration if I changed schema.prisma
  • I updated docs or .env.example if needed

Copilot AI review requested due to automatic review settings May 20, 2026 18:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 findMemberById for the invalid codingLevel scenario.

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.

Comment thread src/controllers/member.controller.ts
Comment thread src/controllers/member.controller.ts
});

it("returns 400 for an invalid codingLevel", async () => {
vi.mocked(memberService.findMemberById).mockResolvedValue(mockMember);
@JokMaker
Copy link
Copy Markdown
Contributor Author

@Nadinefiona @rodriguecyber @Nick-Lemy can you have a look at this PR

@JokMaker JokMaker force-pushed the fix/update-member-existence-check branch from 132fb89 to da971b1 Compare May 20, 2026 18:20
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.
@JokMaker JokMaker force-pushed the fix/update-member-existence-check branch from da971b1 to e2481bd Compare May 20, 2026 18:25
JokMaker and others added 2 commits May 21, 2026 19:31
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.
@JokMaker JokMaker force-pushed the fix/update-member-existence-check branch from fe79365 to 76f8ecc Compare May 21, 2026 17:33
@JokMaker
Copy link
Copy Markdown
Contributor Author

@Nadinefiona @rodriguecyber @Nick-Lemy can you have a look at this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants