North-Seattle-College / ad440-winter2021-thursday-repo

NSC AD 440 Winter 2021 Thursday cohort practicum repo
Apache License 2.0
2 stars 27 forks source link

/taskId PUT failure #288

Closed unicornsleuth closed 3 years ago

unicornsleuth commented 3 years ago

Describe the bug A PUT request fails to update, because of a bug in the code - expects 3 positional arguments, but receives 4 After I quickly/temporarily made this fix, I found that a PUT (and also patch, delete) does not invalidate the particular cache for that task.

To Reproduce Steps to reproduce the behavior:

  1. In VSCode, run the Azure functions
  2. In Postman, run a GET on http://localhost:7071/api/users/1/tasks
  3. Take the first taskId you see (for me, it was 2) and run a GET on http://localhost:7071/users/1/tasks/2
  4. Create a PUT request on http://localhost:7071/users/1/tasks/2 with the raw body:
    {
    "title": "title",
    "description": "description",
    "dueDate": "03/04/21 12:12:12",
    "completed": "0",
    "completedDate": "04/04/21 12:12:12"
    }
  5. See error

Expected behavior You should see "Error: update() takes 3 positional arguments but 4 were given"

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

To Reproduce 2nd Part

  1. You can easily fix this bug by removing the ",r" from line 308 of the /taskId init file
  2. Save & reload functions
  3. Run the PUT request from before (step 4)
  4. Run the GET request from before (step 3) and see that the data has not been updated
  5. Check in VSCode, and see that the output says "Cache cleared" AND "Returned data from cache"
  6. Run the GET request from before (step 2) and see that the data has, in fact, been updated.

Additional context We should have a cache for each task that has been queried, of the form "users:{userId}:tasks:{taskId}" The caches are being created for these, but they are not being cleared when PUT/PATCH/DELETE is run on the task. The code needs to be reworked to invalidate those particular caches as well as the "users:{userId}:tasks" cache on each update.

jaguiniga commented 3 years ago
Date Activity Time Spent
03/219/2021 Testing Bug issue 20 mins
03/21/2021 Researching Solutions 1 hour
03/22/2021 Testing Solutions 2 hours
03/23/2021 Testing deployment 1 hour
03/24/2021 Creating PR 30 mins

How to Test :