Skip to content

Solution#253

Open
CookieTanuki wants to merge 3 commits intomate-academy:mainfrom
CookieTanuki:develop
Open

Solution#253
CookieTanuki wants to merge 3 commits intomate-academy:mainfrom
CookieTanuki:develop

Conversation

@CookieTanuki
Copy link

No description provided.

Copy link

@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

Great work on implementing the profile creation endpoint and email notifications! The code is well-structured and the features work correctly.

However, one change is required to fully meet the task specifications. The task requires that all validation logic be associated with the schema file.

  • In src/schemas/profiles.py, you are required to import validate_image from the validation package. This import is currently missing. Please add it to the file to align with the project's design pattern.

Once you've added this import, the submission will meet all requirements. You're very close to finishing this task!


✨ 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 on lines 8 to 12
from validation import (
validate_name,
validate_image,
validate_gender,
validate_birth_date
)

Choose a reason for hiding this comment

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

According to the task description, you are required to import validate_image from the validation package in this file. Please add it to the import list.

# 5. Avatar upload to s3 storage
try:
validate_image(avatar)
ext = avatar.filename.split(".")[-1]

Choose a reason for hiding this comment

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

This method of getting the file extension might not work as expected for all filenames. For example, if a filename has no extension (e.g., myfile), this will use the entire filename as the extension. For more robust parsing, consider using Python's os.path.splitext or pathlib module.

Copy link

@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 progress on the project! The email notifications and profile endpoint logic are implemented correctly. However, one structural change is needed before this can be approved. The project requires all validation logic to be associated with its schema. Currently, the avatar validation (validate_image) is performed in the create_profile route in src/routes/profiles.py. Please move this validation logic into the src/schemas/profiles.py file. A good approach would be to modify the ProfileCreateSchema.as_form class method to accept the avatar and validate it there. You're very close to completing this!


✨ 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

@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 task! You've successfully implemented all the requirements, and it's great to see that you moved the avatar validation into the schema as requested. Your solution is fully functional and meets all specifications.

To make your code even better, I have a small suggestion for src/schemas/profiles.py. While your current implementation works perfectly, consider using a @field_validator for the avatar field. This would align its validation with the other fields, making your code more consistent and centralizing all the validation logic within the Pydantic pattern.

Since this is a minor point and your code is functionally correct, I am approving your solution to keep you moving forward. Keep up the fantastic work!


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

Footnotes

  1. Rate AI review example

info=info,
avatar=avatar
)
validate_image(avatar)

Choose a reason for hiding this comment

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

Great work moving the avatar validation into the schema as requested!

To make the implementation even more robust and consistent with how other fields are validated, consider using a @field_validator for the avatar field as well. This would centralize all your validation logic under the same Pydantic pattern.

Comment on lines +91 to +95
except ValueError as e:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail=str(e)
)

Choose a reason for hiding this comment

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

If you move the image validation to a @field_validator as suggested above, this except ValueError block may no longer be necessary. Pydantic's field validators automatically convert ValueError exceptions into a single ValidationError, which would then be caught by the except ValidationError block. This would help unify and simplify your error handling.

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