-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pi-hole 6 API: deleting session returns 410 instead of 200 #1833
Comments
It seems our interpretations indeed differ, let's quote the essential of the link you posted:
To me a successful deletion event exactly fulfills this: The resource is already gone when this returns from the API. Let's have a look at RFC 9110 - HTTP Semantics:
Interestingly, nobody is talking about So I went to my book shelf and took out the book "The Design of Web APIs" by Arnaud Lauret but they don't say much. On page 145 we find:
TBH, to me this very much sounds like: Everything is allowed. We can use So far, so unclear? I am absolutely open for further thoughts and possibly also some references how others are doing it. |
I'm far from an expert on this matter, but as far as I know, 4xx codes are Error codes:
My understanding is 410 is used when the client requests for some HTTP resource once available, but not available anymore. From 410 code specification:
This is a special case and not what we have here. In our case, if you successfully requested to delete an item and the item was there, no error occurred. The operation was successful (2xx). |
Thank you for the detailed explanation. I understand your point, but here how I see it. The API docs for this action are stating clear the possible HTTP codes The current results are as follow:
I would rather expect the following result:
However you decide to implement it, it should be documented much clearer so there is no confusion. |
EDITED: I 'm not sure if I understood your explanation about first and second calls...
I think you correctly received a
In my opinion, if you try to delete the same item twice, the first time it will answer with |
This is what I have expected. But currently the API at the first time answer with |
Wait, before we mix some things here, let me first clarify:
As deleting your own session is a very special case, let's instead discuss the behavior of something that does not have such a special behavior like deleting the session of some other user or, even simpler, say
We will then apply our conclusion to all Currently, the API returns We can remove this optimization (make the API a little bit slower) and instead first check if the record exists. If not, then we reply with ... what? TL;DR: Suggestion:
|
Good to know 😃
Ok, my bad. Just read in the API docs that the
Than the |
I pushed by proposal in branch It should become ready for testing in about half an hour. It'd be great if you could check it out and see if the returned codes are now as expected (and as documented). As we are approaching midnight over here, so my own testing was a bit limited. |
@DL6ER I will test it when the PR is merged and new version is released. |
It is unclear when the team will have time to review this. If you could check out this branch before using
and provide feedback, this would tremendously help the process. Furthermore, it'd be much more efficient if we could test and then immediately change the PR than creating a fix, waiting for it to be merged, then merge it and see afterwards that it wasn't sufficient, starting the whole process over again. It could take months to get it eventually fixed in such an iterative approach... |
I would love to do it, but currently I am testing it using a Docker container. I'm not that experienced to get the branch compiled and running. I will try to find a way. Thank you for your efforts! |
Running the command I provided inside the container should "just work" |
Not in v6, a complete custom image will need to be built, but it's pretty straight forward! See: TL;DR
|
Fixing PR has been merged. |
Versions
Platform
Expected behavior
According to the API docs the API should return the status code
200
when a session is deleted.Actual behavior / bug
After the deletion of a session the API returns the
410
status code. To my understaning the HTTP specification recommends that the410
status code is returned at the access of a already deleted entity, not at preforming the delete action itself.Steps to reproduce
Steps to reproduce the behavior:
POST
https://127.0.0.1/api/auth
session.sid
resultDELETE
https://127.0.0.1/api/auth
{ "sid": "SID" }
The text was updated successfully, but these errors were encountered: