Malformed Query Cannot Be Deleted

Issue: A malformed query is "blocking" the Query Library page and I cannot delete it. Cloud v3.117.0

Steps:

  • Whilst setting up a specific resource to an AWS hosted S3 bucket I hit the "Test Query" button next to Connector Version

  • This auto created a new but obviously malformed query in the Query library, but for the wrong type (Big Query Demo).

  • This query appears at the top of the Your Queries so becomes the default when that page is navigated to.

  • No ellipsis appears near the play button so it cannot be deleted.

  • The query components like action type are responsive but do not persist the selection

  • You cannot navigate to another query as they are non-responsive.

  • The Retool menu is still active so you can navigate away but on the return the same behaviour persists.

  • I have logged out and back in again at which point I get a message saying "it looks like we couldn't find this query" (see attached) and the same behaviour happens.

  • I have switched browsers and that didn't work

Any advice on how to cull it would be greatly appreciated.

I have found a temporary workaround by creating another new query but from the Query Library page so that becomes the top/default query on the page load. This at least lets me get to my existing queries but I cannot navigate to the broken one and hence still can't delete it.


Screenshot 2024-11-13 at 13.46.32

Hello @derek_c!

Apologies for this issue.

I have seen one other case where another user had a similar 'zombie' query that they were not able to delete.

The usual flow for removing a query that can't be deleted would be to do some 'database surgery' to remove the query from the app's records of queries.

Since you are on cloud, we would have an engineer from our team oversee this to ensure the correct query and only that is removed. We would need your orgId/domain and the name of the query. You can DM that to me on this forum as those are private.

The issue that occurred with the other user involved the query being in a "protected" state. This is normally caused by version control as a safety measure. In the case of the other user it was caused by an old and deprecated template for an S3 resource :sweat_smile:

Were you by chance using a template or version control when this query was created?

I see you mention you used a "Test Query" button that was next to the Connector version, I was trying to reproduce this bug but didn't see that option from the resource set up page :face_with_monocle:

If you can share screen shots of how you set the query up I can try to reproduce this bug to make sure it gets fixed! :saluting_face:

Hi @Jack_T I think I've got a similar issue except this is within the scope of my app. I had some queries (one to post to slack and the other to run a JS query) - this worked and then I had an issue where it was saying it could not fetch. Now whatever I try I cannot delete or save changes to my query. If I delete it says it's been deleted but if I refresh it appears again... I am now unable to make any changes to my app. I have tried cloning but still got the same issue.

Hi @neves,

I am sorry to hear that.

Are these queries from your Query Library? Are you self-hosted or on the cloud?

If you are on the cloud, if you could DM me your org name name and the query name I can see if an engineer can do some DB surgery to delete the query from your org.

Hello @derek_c and @neves!

Great news, just got word on how to delete these queries.

I know that I mentioned one option before but this is much better, as we prefer not to do any DB surgery on our cloud servers as this is bad practice and should only be used as a last resort.

The better option for deleting queries is to use the Retool API to directly send a request to delete the query if the UI is not able to do so. The code snippet is what the delete button in the UI runs under the hood.

First: From your Retool app, open up the browser inspector, navigate to the console and run the following script to get the IDs of your queries. The returned list will include Query Library queries as well as app specific queries.

fetch('/api/playground', {
  'headers': {
    'x-xsrf-token': document.cookie.split('xsrfToken=')[1].split(';')[0]
  }
}).then(r => r.json()).then(d => console.log(d))

The result should look something like this(ignore the errors).

The ID we need to ass into the delete is the numeric ID on the left (not the UUID, which has letters in it).

Now we can run the delete fetch request with the ID of the query we are looking to remove. The code snippet is as follows:

// Replace QUERY_ID with numeric ID
fetch('/api/playground/QUERY_ID/delete', {
  'headers': {
    'x-xsrf-token': document.cookie.split('xsrfToken=')[1].split(';')[0]
  },
  'method': 'DELETE'
}).then(r => r.json()).then(d => console.log(d))

This should work to remove these queries that do not have a delete button!

Let me know if this works or if the console log gives back something unexpected :crossed_fingers:

Thanks @Jack_T that worked !!!

1 Like

@derek_c great to hear!

Glad I could help.