ita-social-projects / SpaceToStudy-BackEnd

MIT License
13 stars 5 forks source link

[API PATCH /users/{id}. Edit tutor's profile] Status 500 when ommiting keys in JSON. #985

Open MilaKomisarenko opened 6 days ago

MilaKomisarenko commented 6 days ago

Reproducible: always

Pre-conditions:

  1. The site Space2Study is opened.
  2. The user is logged in as a Tutor.
  3. The Postman app is opened.
  4. The user's access token is available and added to the Postman headers.

Steps to reproduce:

  1. Choose the PATCH method in Postman.

  2. Add the endpoint {server}/users/{user_id} in the URL field, replacing {server} with the actual server address and {user_id} with the user's ID.

  3. In the Body tab, select the raw type and set the data format to JSON.

  4. Enter the following test data in the body: { "mainSubjects": { "tutor": [ { "_id": "4de73c1f-1377-4723-ab99-484ecc478144", "subjects": [ { "_id": "66758f4059019cd05eb11a98", "name": "Operating Systems" }, { "_id": "66758f4059019cd05eb11a99", "name": "Cybersecurity" } ] } ] } }

  5. Send the request.

Actual result: Status code 500 is returned. { "status": 500, "code": "INTERNAL_SERVER_ERROR", "message": "Cannot read property '_id' of undefined" } Image

Expected result: Status code 4xx is returned.