Problem
In certain versions of Terraform Enterprise, API filtering may not function as expected. For example, when using the List Workspaces API to filter runs by status, the API returns all runs instead of only those matching the specified filter.
This example command attempts to filter for runs with a discarded status, but the output incorrectly includes runs with other statuses.
$ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ "https://<TFE_URL>/api/v2/workspaces/ws-KgwBndLB7gc5wo5C/runs?filter%5Bstatus%5D=discarded&fields%5Brun%5D%5B%5D=status" | jq '.'

Cause
This is a known issue in the July 2022 Terraform Enterprise releases, specifically versions v202207-1 and v202207-2.
Solution
To resolve this issue, you must upgrade your Terraform Enterprise instance to a more recent version.