fix(cognito): fail listUsers/listUserPoolClients on an absent user pool (#2962)

listUsers scanned its store by a "{poolId}::" prefix and
listUserPoolClients by a userPoolId field, neither of which touched
poolStore, so a pool id that does not exist was indistinguishable from
an empty pool: both returned 200 with an empty list instead of
ResourceNotFoundException. list-groups and list-resource-servers
already resolved the pool via describeUserPool and were correct;
this brings the other two list actions in line with them and with
real Cognito, where all four behave identically.

Fixes #2952
This commit is contained in:
Olamide Kosile authored and GitHub committed 2026-09-03 11:05:20 -04:00
1 parent 262495df67
commit 4bf17a1fe2
2 files changed
+39

No files matched your search

@@ -651,6 +651,7 @@ public class CognitoService implements ResourceProvider {
}
public List<UserPoolClient> listUserPoolClients(String userPoolId) {
describeUserPool(userPoolId);
return clientStore.scan(k -> clientStore.get(k).map(c -> c.getUserPoolId().equals(userPoolId)).orElse(false));
}
@@ -1661,6 +1662,7 @@ public class CognitoService implements ResourceProvider {
}
public List<CognitoUser> listUsers(String userPoolId, String filter) {
describeUserPool(userPoolId);
String prefix = userPoolId + "::";
List<CognitoUser> all = userStore.scan(k -> k.startsWith(prefix));
if (filter == null || filter.isBlank()) {