Ivan-Johnson / LifeLogServer

A DIY life tracking app
0 stars 0 forks source link

Take steps to ensure database integrity #21

Closed Ivan-Johnson closed 4 years ago

Ivan-Johnson commented 4 years ago

It's possible for an endpoint to modify the database and then return an error code; e.g. a POST to weight/record might add weight data, but return "500 Internal Server Error" because of a bug. I want to be able to ~guarantee to the client that non-200 status codes do not modify the database. (I can't imagine a realistic scenario where modifying the database for a non-200 status code is the intended behavior)

I'm not certain it's possible, but I'd like it if endpoints weren't able to modify the database at all and instead made transactions that a decorator of the endpoint would apply iff the endpoint returns a status code of 200.

Ivan-Johnson commented 4 years ago

It's worth noting that this issue is closely related to #5; I imagine that they could be implemented simultaneously with a "modifiesDB" decorator.

Ivan-Johnson commented 4 years ago

I've put some more thought into it, and realized that it shouldn't be hard to remember to never commit anything before confirming that the operation is a success. Even so, I don't trust myself to remember it so I'll be implementing this anyways.