uport-project / lambda-chasqui

🏃 Messenger service 🏃
Apache License 2.0
6 stars 1 forks source link

Updating/getting a nonexistent topic returns 200 OK #5

Open rmw2 opened 6 years ago

rmw2 commented 6 years ago

Expected behavior: Posting to a recently deleted topicid should result in a 404 or other error, indicating that the resource doesn't exist.

Attempting to GET a non-existent topicid will also return 404 Not Found or (per previous spec) create a new topic and return 201 Created same as POST /topic/

Current behavior: Posting to an unused topic does nothing but raises no error, because

UPDATE topics SET content = $2 WHERE id = $1

does nothing when there are no rows with the queried id. The request then returns 200 OK, indicating that it successfully updated a topic when none exists.

Attempting to GET the same topic will return another 200 OK after actually creating an entry for that topic, and will return a body with only {status: 'success'} and no topic field.

Now that new topics are created with POST /topic/ I think it would make sense to remove the GET /topic/:id option, both for redundancy/confusion and for better https semantics.

PR with integration tests/reproducing examples for the above forthcoming

rmw2 commented 6 years ago

POSTing to an unused topicId is fixed now in #7 and returns a 404. Leaving this issue if we want to fix this for GET later.