pev2
pev2 copied to clipboard
How to delete shared plan on explain.dalibo.com?
Is there a way to delete accidentally shared plans on explain.dalibo.com?
I'll suppose that the plan was submitted using the form in your browser (ie. not from an external tool).
Once you have clicked the "share" button and got a unique shareable URL for your plan, the current only way to delete it from the server is to go to the home page at explain.dalibo.com, find the plan in the list on the right, click the trash icon button. Then you have to switch the "Also delete from server" button on.
Is that what you are trying to do?
Please forget my previous answer because apparently your using a tool or a service which sends plan to explain.dalibo.com. I saw your question in https://github.com/Giorgi/LINQPad.QueryPlanVisualizer/issues/29
explain.dalibo.com exposes a POST service on /new
. It actually receives the plan data, stores it in the database, generates an id for plan and automatically redirects the browser to the plan's URL.
What can also be done (and which is currently not documented) is sending the data to /new.json
. In this case, the service response will be in JSON and will like the following:
$ curl -Ls -w %{url_effective} -d '{"plan":"Seq Scan on tenk1 (cost=0.00..333.00 rows=10000 width=148)"}' -H "Content-Type: application/json" -X POST https://explain.dalibo.com/new.json | jq
{
"deleteKey": "feDT5LHZNCUZ2PKY8cfToI4IgZgximFvXP7nsxKTgFjyUpVCS4",
"id": "w9F"
}
It is then possible to ask the service to delete the plan using a DELETE request on /plan/<id>/<deleteKey>
.
The tool or application you're using will have to manage this itself.
ping @Giorgi
My apologizes for this feature to be hidden. I'm considering plublishing explain.dalibo.com code source.
Also in a previous version of the service, users sharing a plan using the interface where given the delete link in an "alert" box. Just like depesz does.
I should probably consider putting this feature back in place. What do you think?
@pgiraud So I should only change the endpoint to get JSON response right?
I don't think this will be enough unfortunately. You'll probably have more work to do like: read the response, store the deleteKey, open a browser window to the plan id URL, add a button for the user if he wants to delete the plan.
Putting the "delete link alert" back may be a good option. In this case, you would have nothing to do on your side. I'm wondering what @agneum and @richyen (who added support for explain.dalibo.com in https://github.com/agneum/plan-exporter) think about this.
Yes, I know that I will have to do that but my question was what I need to change to get the JSON response instead of the Html
Changing the endpoint to new.json
should be enough.
@pgiraud Thanks for looking into this. Yes I strongly believe user should be given the option to delete stored plans.
Most ideally, an authentication system would be used for storing/sharing, like the major online code fiddling/pastebin sites.
But I'd completely understand why you may not want to do that for this project. In that case, a deletion link is probably the next best thing.
For that, the one-time deletion link you mentioned that existed before would help.
Or even better, would you consider letting the user entering his/her own "deletion key" (sort of a passcode) at the time of sharing, and simply store the salted+hashed version of that key alongside the plan, so that the user can delete it later using the key? This way, you shift the responsibility/control of this matter to the user.
Yet another approach is to give the user the option to enter an email address when sharing, and later if the user wants to have the plan deleted, it can be done via a magic link sent to that email address.
Finally, I recommend that you consider adding some privacy policy/disclaimer sort of wording/page to the site, which includes warnings about any private data/security concerns as well as any standard "no liability" clauses etc. Example https://www.brentozar.com/pastetheplan/
Depending on the jurisdiction, this could be a legal requirement. Despite your service being 100% free (and thank you so much for it), it's always better to cover some bases!
I don't think this will be enough unfortunately. You'll probably have more work to do like: read the response, store the deleteKey, open a browser window to the plan id URL, add a button for the user if he wants to delete the plan.
Putting the "delete link alert" back may be a good option. In this case, you would have nothing to do on your side. I'm wondering what @agneum and @richyen (who added support for explain.dalibo.com in https://github.com/agneum/plan-exporter) think about this.
This feature can be implemented if a link (or special identifier) for deletion is returned in the response.
I suppose plan-exporter
could display a link for deletion next to the link to a plan. Is deletion supported by GET
method?
I am trying to implement this optional delete capability and it is not working for me. Any thoughts on what I am doing wrong? I am using Nodejs https module with a request like
request: {
hostname: 'explain.dalibo.com',
path: '/plan/31u/QPDtBPkAh4cgChdsjt6cDJdszbZklvgrqBr4CecBo3KG2FU8M8',
port: 443,
method: 'DELETE'
}
I get the following response:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
@mgetz can you have a try with a simple 'GET' method?
Changing the method from DELETE to GET worked great! Thank you!
Quick follow-up here. The code of the Flask application running explain.dalibo.com as been published. In case it helps you. See https://github.com/dalibo/pev2/issues/390#issuecomment-892599434
https://github.com/dalibo/explain.dalibo.com
@pgiraud I accidently forgot to enable this switch.
Then you have to switch the "Also delete from server" button on.
I have the plan ID saved in a backup file. Is there a way to get the delete key to delete the plan?
Right now it's impossible to delete the plan if it doesn't appear on the home page list.
@pgiraud Any suggestion for above? 👆🏻
Can you please send me an PM on twitter with the ID of the plan? I'll have to trust you that this plan is yours.
My twitter account is @pgira.
Ping @desaiuditd or can you share your email address?
@pgiraud Can't message you on Twitter. I've followed you. Maybe you need to follow me back? 🤷🏻♂️
