Skip to content

Add PUT /users/:id update endpoint - #124

Open
milangit wants to merge 3 commits into
mate-academy:mainfrom
milangit:feat/update-user-endpoint
Open

Add PUT /users/:id update endpoint#124
milangit wants to merge 3 commits into
mate-academy:mainfrom
milangit:feat/update-user-endpoint

Conversation

@milangit

@milangit milangit commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • Add updateUser to db/store.js, following the existing getUserById/createUser pattern (returns undefined when the id doesn't exist).
  • Add PUT /users/:id to routes/users.js: validates name and email (presence, type, basic email shape) with per-field 400 errors, returns 404 when the user isn't found, 200 with the updated user otherwise.
  • Add NOTES.md documenting the plan, model choice, commit split, and review.

Test plan

  • npm test — all 9 tests pass, including the three tests/update-user.test.js cases (200 update, 404 unknown id, 400 missing field)
  • npm run lint — clean
  • Manually exercised PUT /users/:id with invalid email shape, wrong-typed fields, non-numeric id, and empty body — all return 400/404 as expected, no crashes

🤖 Generated with Claude Code

milangit and others added 3 commits September 2, 2026 01:10
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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.js file that defines PUT /users/:id with input validation and proper 404 handling. Ensure it calls updateUser from the store. Without this, the endpoint won’t exist and tests will fail.
  • Include the updated db/store.js with the updateUser helper 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@milangit

milangit commented Sep 1, 2026

Copy link
Copy Markdown
Author

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.
That mentor comment doesn't match the real state of PR #124 — worth telling it (or whoever's reading it) that. Nothing to fix on your end; the code is there and verifiable via the PR diff.

Please check it again.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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