pev2 icon indicating copy to clipboard operation
pev2 copied to clipboard

How to delete shared plan on explain.dalibo.com?

Open felinepc opened this issue 3 years ago • 17 comments

Is there a way to delete accidentally shared plans on explain.dalibo.com?

felinepc avatar Mar 03 '21 19:03 felinepc

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?

pgiraud avatar Mar 04 '21 07:03 pgiraud

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. Capture d’écran du 2021-03-04 08-30-01 I should probably consider putting this feature back in place. What do you think?

pgiraud avatar Mar 04 '21 07:03 pgiraud

@pgiraud So I should only change the endpoint to get JSON response right?

Giorgi avatar Mar 04 '21 07:03 Giorgi

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.

pgiraud avatar Mar 04 '21 08:03 pgiraud

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

Giorgi avatar Mar 04 '21 08:03 Giorgi

Changing the endpoint to new.json should be enough.

pgiraud avatar Mar 04 '21 08:03 pgiraud

@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!

felinepc avatar Mar 04 '21 16:03 felinepc

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?

agneum avatar Mar 05 '21 15:03 agneum

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 avatar Jun 30 '21 13:06 mgetz

@mgetz can you have a try with a simple 'GET' method?

pgiraud avatar Jul 01 '21 14:07 pgiraud

Changing the method from DELETE to GET worked great! Thank you!

mgetz avatar Jul 01 '21 14:07 mgetz

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 avatar Aug 04 '21 12:08 pgiraud

@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.

desaiuditd avatar Jan 11 '23 08:01 desaiuditd

@pgiraud Any suggestion for above? 👆🏻

desaiuditd avatar Feb 07 '23 02:02 desaiuditd

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.

pgiraud avatar Feb 08 '23 07:02 pgiraud

Ping @desaiuditd or can you share your email address?

pgiraud avatar Feb 09 '23 14:02 pgiraud

@pgiraud Can't message you on Twitter. I've followed you. Maybe you need to follow me back? 🤷🏻‍♂️

image

desaiuditd avatar Feb 10 '23 15:02 desaiuditd