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.setMethod('GET'); req.setHeader('Authorization','Bearer '+accessToken); String urlQuery = EncodingUtil.urlEncode('SELECT Id, FlowVersionId FROM FlowElementTestCoverage WHERE FlowVersionId = \'[myFlowVersionId]\' LIMIT 1', 'UTF-8'); req.setEndpoint('https://[domain].my.salesforce.com/services/data/v49.0/tooling/query/?q='+urlQuery); HttpResponse res = new Http().send(req); System.debug(res.getStatusCode()); System.debug(res.getStatus());
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.