Add PUT /users/:id update endpoint - #124
Conversation
Looks up the user by id and updates name/email in place, returning undefined when the id doesn't exist, matching getUserById's existing not-found contract. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Validates name and email (presence, type, basic email shape) with per-field 400 errors, updates the user via store.updateUser, and returns 404 when the id doesn't exist instead of crashing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the PR as provided is missing critical code files required by the task. The assignment requires implementing PUT /users/:id in routes/users.js with validation (400 for missing/invalid fields) and 404 for non-existent users, and updating via db/store.js. However, only NOTES.md is visible in this submission; routes/users.js and db/store.js changes are not included, which prevents verification and would block functionality if merged without those files.
Critical issues to fix:
- Include the updated
routes/users.jsfile that definesPUT /users/:idwith input validation and proper 404 handling. Ensure it callsupdateUserfrom the store. Without this, the endpoint won’t exist and tests will fail. - Include the updated
db/store.jswith theupdateUserhelper actually implemented in this PR scope so reviewers and CI can execute tests.
Why this matters: the core requirement is the working endpoint and store update; missing source files are a blocker. How to fix: push the commits that add/modify routes/users.js and db/store.js, or re-open the PR with those diffs. Once the code is present and tests pass, this looks otherwise aligned with the expectations documented in your NOTES.md. Keep the clear validation and not-found behavior you described—those are on point.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
|
I think this statement is not true: "However, only NOTES.md is visible in this submission; routes/users.js and db/store.js changes are not included, which prevents verification and would block functionality if merged without those files." Because in "Files changed" of this PR and can see also user.js and store.js. Also Claude had confirmed that this PR is OK. Message from Claude is: The diff confirms it end to end — the actual code changes for db/store.js and routes/users.js are in the PR, not just NOTES.md. Please check it again. |
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
Summary
updateUsertodb/store.js, following the existinggetUserById/createUserpattern (returnsundefinedwhen the id doesn't exist).PUT /users/:idtoroutes/users.js: validatesnameandemail(presence, type, basic email shape) with per-field 400 errors, returns 404 when the user isn't found, 200 with the updated user otherwise.NOTES.mddocumenting the plan, model choice, commit split, and review.Test plan
npm test— all 9 tests pass, including the threetests/update-user.test.jscases (200 update, 404 unknown id, 400 missing field)npm run lint— cleanPUT /users/:idwith invalid email shape, wrong-typed fields, non-numeric id, and empty body — all return 400/404 as expected, no crashes🤖 Generated with Claude Code