Skip to content

Solution#1105

Open
ivan-major wants to merge 3 commits intomate-academy:masterfrom
ivan-major:develop
Open

Solution#1105
ivan-major wants to merge 3 commits intomate-academy:masterfrom
ivan-major:develop

Conversation

@ivan-major
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Review Summary

Your implementation is very well-structured, and you've correctly handled the URL parsing and validation logic. However, this requires a change because the error handling is incomplete. When validation fails, the server is required to send a 400 Bad Request status. Your code currently sends the default 200 OK, which would cause any client to misinterpret the error response as a success.

To fix this, please update src/createServer.js to set res.statusCode = 400 and res.statusMessage = 'Bad request' before sending the JSON error payload. This is a crucial part of building a compliant API.


✨ 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

Comment thread src/createServer.js
res.setHeader('content-type', 'application/json');

if (errors.length > 0) {
res.end(JSON.stringify({ errors }));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When validation fails, the response should have a 400 status code and 'Bad request' status text. Currently, the response is sent with the default 200 status. You should set res.statusCode and res.statusMessage before sending the error response.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Review Summary

Excellent work on this iteration! You've done a great job implementing the 400 status code for validation errors, and the server is now very close to perfect. However, one small change is needed to fully meet the requirements. The specification requires the status message for a 400 error to be 'Bad request', with a lowercase 'r'. Your current implementation uses 'Bad Request'. While this might seem minor, it's crucial for passing the automated tests which perform a strict string comparison. Please update the res.statusMessage in src/createServer.js to match the required casing, and then we'll be ready to approve.


✨ 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

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Review Summary

Excellent work! You've successfully addressed the feedback from the previous review by correcting the status message for 400 errors to Bad request. Your server implementation is now robust, handles all validation cases correctly, and perfectly meets all the project requirements. The code is clean and well-structured. I'm happy to approve this submission. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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