Problem
The pagination metadata (meta.pagination) in the response from the Admin List All Organizations API is incorrect relative to the total number of organizations.
For example, in a Terraform Enterprise instance with twenty-five organizations, a request using the default page size of twenty should receive pagination metadata reporting two total pages with a total count of twenty-five. Instead, the API may return an inaccurate response similar to the following example.
{
"meta": {
"pagination": {
"current-page": 1,
"prev-page": null,
"next-page": 2,
"total-pages": 3,
"total-count": 45
}
}
}This issue results in the API reporting more pages than actually contain organizations. While the API returns an empty JSON array for pages beyond the actual total and does not cause errors in clients that can handle empty arrays, it may cause clients to make more requests than necessary as they follow the inaccurate pagination controls.
Prerequisites
- Terraform Enterprise version
v202406-1or later. - Organizations have multiple organization owners.
Cause
This is a known bug in Terraform Enterprise versions v202406-1 and later. The pagination counts are inaccurately calculated based on the total number of organization owners instead of the total number of organizations.
HashiCorp engineering is addressing this bug. This article will be updated with the version that includes the fix when it becomes available.
Solutions
Solution 1: Upgrade Terraform Enterprise
When available, upgrade to a version of Terraform Enterprise that contains the fix for this bug.
Solution 2: Implement a Client-Side Workaround
As a temporary workaround, you can implement pagination in clients that use this API by manually calculating the total pages. Use the meta.status-counts.active attribute, which accurately represents the total number of active organizations.
Use the following formula to calculate the total number of pages and continue to request pages until this total has been reached.
total_pages = ceiling(meta.status-counts.active / page_size)