Sunagatov / Iced-Latte

a online Marketplace for coffee retail (Backend)
https://iced-latte.uk
MIT License
586 stars 95 forks source link

Update user's info with empty body. Invalid error message. #275

Open TetianaPerinha opened 2 months ago

TetianaPerinha commented 2 months ago

Description: When sending a request to update user's info with an empty body, the app return a clear error message in string format.

Precondition: The user authorized and gets Bearer token

Steps to Reproduce: replace token with valid data Send a PUT request to the endpoint http://localhost:8083/api/v1/users using the HTTP PUT method with an empty JSON object {} as the body. ‌ curl --location --request PUT 'http://0.0.0.0:8083/api/v1/users' --header 'Content-Type: application/json' --header 'Authorization: Bearer {token}'{ }' ‌

  1. Observe response message.

Expected result: format message should be a string. "First name is the mandatory attribute" and "Last name is the mandatory attribute"

Actual result: format message is list dictionary.

image

SaiSamyuG commented 3 weeks ago

Hi @TetianaPerinha I would like to take up this issue. Could you assign it to me

TetianaPerinha commented 3 weeks ago

Hi @TetianaPerinha I would like to take up this issue. Could you assign it to me

Hey @DarsiSreelekha, I've assigned this task to you. If you have any questions, feel free to ask.

SaiSamyuG commented 3 weeks ago

Hi @TetianaPerinha @Sunagatov

  1. To customize the error response for the update users api, the ideal approach I think would be adding custom error messages for fields in UpdateUserAccountRequest. Eg: @NotNull(message="First name is the mandatory attribute") for firstname and add an exception handler.
  2. But the class is a generated one from com.zufar.icedlatte.openapi.dto which is a mentioned dependency in pom.xml.
  3. Could you help me in modifying it if it's okay for you or else I will try another alternative approach if possible.
TetianaPerinha commented 3 weeks ago

Hi @TetianaPerinha @Sunagatov

  1. To customize the error response for the update users api, the ideal approach I think would be adding custom error messages for fields in UpdateUserAccountRequest. Eg: @NotNull(message="First name is the mandatory attribute") for firstname and add an exception handler.
  2. But the class is a generated one from com.zufar.icedlatte.openapi.dto which is a mentioned dependency in pom.xml.
  3. Could you help me in modifying it if it's okay for you or else I will try another alternative approach if possible.

@Sunagatov Could you help, please?

SaiSamyuG commented 2 weeks ago

Hi @TetianaPerinha @Sunagatov

  1. To customize the error response for the update users api, the ideal approach I think would be adding custom error messages for fields in UpdateUserAccountRequest. Eg: @NotNull(message="First name is the mandatory attribute") for firstname and add an exception handler.
  2. But the class is a generated one from com.zufar.icedlatte.openapi.dto which is a mentioned dependency in pom.xml.
  3. Could you help me in modifying it if it's okay for you or else I will try another alternative approach if possible.

@Sunagatov Could you help, please?

Hi @TetianaPerinha @Sunagatov

  1. To customize the error response for the update users api, the ideal approach I think would be adding custom error messages for fields in UpdateUserAccountRequest. Eg: @NotNull(message="First name is the mandatory attribute") for firstname and add an exception handler.
  2. But the class is a generated one from com.zufar.icedlatte.openapi.dto which is a mentioned dependency in pom.xml.
  3. Could you help me in modifying it if it's okay for you or else I will try another alternative approach if possible.

I understood that the dto class UpdateUserAccountRequest is generated from openapi spec. So, have made necessary changes in the same and raised PR. Please review it. https://github.com/Sunagatov/Iced-Latte/pull/317