Skip to content

Commit 3e3489d

Browse files
[PATCH] Enable pagination on Client Connection (#917)
This pull request introduces a new upstream patch. In a [recent upstream release](https://github.com/auth0/terraform-provider-auth0/releases/tag/v1.22.0), an extra GET call was implemented on Create for ConnectionClients. This call does not implement pagination properly, so that when there are more clients in existence than clients returned per page, it is possible that Create can fail if the new client's ID is on page 2 of the request. This intermittent failure was reported in #909. There is no obvious way to test this. The default clients-returned-per-page is 50; our Auth0 instance does not permit that many clients. I've tested this locally by implementing the upstream provider with a very small PerPage for the Client, which reproduced the error reported in #909 reliably. This is also something that we should be able to fix upstream, so I'll open a pull request there as well.
1 parent 1a28e7e commit 3e3489d

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: guineveresaenger <[email protected]>
3+
Date: Mon, 28 Jul 2025 16:27:42 -0700
4+
Subject: [PATCH] Enable pagination via Next on reading upstream connection
5+
client
6+
7+
8+
diff --git a/internal/auth0/connection/resource_client.go b/internal/auth0/connection/resource_client.go
9+
index 010f0fe8..99953184 100644
10+
--- a/internal/auth0/connection/resource_client.go
11+
+++ b/internal/auth0/connection/resource_client.go
12+
@@ -81,13 +81,34 @@ func readConnectionClient(ctx context.Context, data *schema.ResourceData, meta i
13+
connectionID := data.Get("connection_id").(string)
14+
clientID := data.Get("client_id").(string)
15+
16+
- enabledClientsResp, err := api.Connection.ReadEnabledClients(ctx, connectionID)
17+
- if err != nil {
18+
- return diag.FromErr(internalError.HandleAPIError(data, err))
19+
+ // Implement pagination using the Next token
20+
+ var allClients []management.ConnectionEnabledClient
21+
+ var next string
22+
+
23+
+ for {
24+
+ var enabledClientsResp *management.ConnectionEnabledClientList
25+
+ var err error
26+
+
27+
+ if next == "" {
28+
+ enabledClientsResp, err = api.Connection.ReadEnabledClients(ctx, connectionID)
29+
+ } else {
30+
+ enabledClientsResp, err = api.Connection.ReadEnabledClients(ctx, connectionID, management.From(next))
31+
+ }
32+
+
33+
+ if err != nil {
34+
+ return diag.FromErr(internalError.HandleAPIError(data, err))
35+
+ }
36+
+
37+
+ allClients = append(allClients, enabledClientsResp.GetClients()...)
38+
+
39+
+ if !enabledClientsResp.HasNext() {
40+
+ break
41+
+ }
42+
+ next = enabledClientsResp.Next
43+
}
44+
45+
found := false
46+
- for _, c := range enabledClientsResp.GetClients() {
47+
+ for _, c := range allClients {
48+
if c.GetClientID() == clientID {
49+
found = true
50+
break

0 commit comments

Comments
 (0)