Code RoomProfile update loses existing fields
HardPrep Room Coding #1979

Profile update loses existing fields

Code reviewCode quality & reviewSenior–Staff~25 min

Review this TypeScript handler for `PATCH /users/:id` that updates a user profile.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1app.patch('/users/:id', async (req, res) => {
2 const body = req.body as Partial<UserProfile>;
3 const updated: UserProfile = {
4 name: body.name,
5 email: body.email,
6 bio: body.bio,
7 phone: body.phone,
8 notifications: body.notifications,
9 };
10 await db.users.replace(req.params.id, updated);
11 res.json(updated);
12});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.