We've got an issue regarding Salesforce improperly cleaning out FlowElementTestCoverage records, leaving over a million "stranded" on an old/inactive Flow Version. This is causing us to be unable to delete said Flow Version.

The object in question can only be queried/deleted via the Tooling API, and I've written the following just to test retrieval:

HttpRequest req = new HttpRequest();
req.setHeader('Authorization','Bearer '+accessToken);

String urlQuery = EncodingUtil.urlEncode('SELECT Id, FlowVersionId FROM FlowElementTestCoverage WHERE FlowVersionId = \'[myFlowVersionId]\' LIMIT 1', 'UTF-8');

HttpResponse res = new Http().send(req);

Problem is, I always get System.CalloutException: Read timed out. However, when I remove the WHERE clause such that the query is SELECT Id, FlowVersionId FROM FlowElementTestCoverage LIMIT 1, it works fine.

I guess I'm just a little lost as to how to proceed. I don't understand how adding a FlowVersionId filter would cause this problem.

1 Answer 1


Well, in thinking further about the WHERE clause specifically causing the issue, I wondered if it was a spacing issue. I edited that line to remove spaces in the SELECT and WHERE:

SELECT Id,FlowVersionId FROM FlowElementTestCoverage WHERE FlowVersionId=\'[myFlowVersionId]\' LIMIT 1'

...and it worked!

  • White space in the WHERE clause shouldn't be causing a time out exception. Are they correctly URL encoding as %20? Jul 27, 2020 at 18:56
  • @DanielBallinger I just checked and indeed, it is NOT encoding it correctly. Instead, it's doing: SELECT+Id+FROM+FlowElementTestCoverage+WHERE+FlowVersionId+%3D+%27[myFlowVersionId]%27+LIMIT+1
    – Mike
    Jul 27, 2020 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.