ucsb-cs156-s21 / proj-ucsb-cs-las

https://proj-ucsb-cs-las.herokuapp.com/
MIT License
2 stars 3 forks source link

Backend route to delete a course returns 500 #277

Open pconrad opened 3 years ago

pconrad commented 3 years ago

Bug Report

Backend route to delete a course returns 500. This makes it impossible to delete a course.

Steps to Reproduce

  1. Bring up two windows to the app. Log in to both. In first, bring up /swagger-ui/index.html. In second, go to the courses page, to list the courses. (You'll need the id values).
  2. In a separate window, get the Bearer token needed to work with swagger-ui
  3. Go to swagger ui window and go to the GET route /api/member/courses and make sure that the token works to list the courses. You should get a response code of 200, not 500, and a JSON list of courses.
  4. Now go to the DELETE route and try to delete one of the courses.

Expected / Desired Behavior

A 200 response and JSON showing that the course was deleted.

Observed / Actual Behavior

A 500 response and this error JSON:

{
  "timestamp": 1622221082340,
  "status": 500,
  "error": "Internal Server Error",
  "message": "could not execute statement; SQL [n/a]; constraint [fk27jy419dq1wprrmncet75njds]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement",
  "path": "/api/admin/courses/1"
}

Discussion

This may have to do with cascading deletes... i.e. removing all of the records that may depend on this course, i.e. tutor assignments, office hours, tutor notes, etc.