CS3219-AY2425S1 / cs3219-ay2425s1-project-g34

nus-cs3219-ay2425s1-cs3219-ay2425s1-project-project-template created by GitHub Classroom
MIT License
3 stars 2 forks source link

Unable to edit a question #12

Closed ChillinRage closed 1 month ago

ChillinRage commented 1 month ago

Problem

Unable to edit a question's field (description etc.) except for the title. Picture shown below (editing the description)

image image

Expected behavior: successfully updating the Hihi question with the new description. Actual behavior: image

Error

There is an inconsistency with how the backend checks for changes and how the frontend formats the requests. The requests contains the full details of a question (including the unedited details), but the backend assumes that any field provided in the request are new values to be updated. This causes the backend to think that the "new" title is conflicting with an existing question, throwing the 409 error.

Proposed fix

Quick fix: under question-controller.js line 174, replace the condition with existingQuestion && existingQuestion.id !== id.

But in the long term, this inconsistency between the front and back ends might cause other problems. Either the front-end changes how it formats the field, or the back-end changes how it handles request fields.