denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[KV Feedback]: improve Deno.KvCommitError message #501

Open ngdangtu-vn opened 1 year ago

ngdangtu-vn commented 1 year ago

🔍

Type of feedback

General feedback

Description

I have a case where delete() atomic operator returns {ok:true} when deleting non-exist keys. This behavior confused me for half of a day because I thought it would return {ok:false} if key not found.

Steps to reproduce (if applicable)

Expected behavior (if applicable)

Return {ok:false}

Possible solution (if applicable)

I think it would be better if we replace ok property with {status: int}. We can implement the SQLite response code system for case. It can offer a better debugging experience.

Additional context

No response

losfair commented 1 year ago

The reason why we don't currently provide a mechanism to get whether a delete() actually operated on an existing key is that a blind delete with a non-discarded result is almost always incorrect, and we would like to guide users to use the atomic() API to do it properly.

Say for example you are deleting a user with login "alice". If you call the delete() API, there's a risk of deleting the wrong user: what if between (some previous operation that lead the app logic to delete the user) and the actual delete() call, the user was deleted and another user was created with the same login?

Can you explain your use case a bit?