diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php index 64c922fc8b..2eac8e73f0 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/XList.php @@ -76,8 +76,13 @@ class XList extends Action $actions = Base::getProviderActions(); $documents = []; - foreach ($actions as $providerId => $updateClass) { - if (!($providers[$providerId]['enabled'] ?? false)) { + foreach ($providers as $providerId => $config) { + $updateClass = $actions[$providerId] ?? null; + if ($updateClass === null) { + continue; + } + + if (!($config['enabled'] ?? false)) { // Disabled by Appwrite configuration, exclude from response continue; } diff --git a/tests/e2e/Services/Project/OAuth2Base.php b/tests/e2e/Services/Project/OAuth2Base.php index 5959a584ea..8a317f3e1d 100644 --- a/tests/e2e/Services/Project/OAuth2Base.php +++ b/tests/e2e/Services/Project/OAuth2Base.php @@ -81,6 +81,19 @@ trait OAuth2Base } } + public function testListOAuth2ProvidersSortedAlphabetically(): void + { + $response = $this->listOAuth2Providers(); + + $this->assertSame(200, $response['headers']['status-code']); + + $ids = \array_column($response['body']['providers'], '$id'); + $sorted = $ids; + \sort($sorted); + + $this->assertSame($sorted, $ids); + } + /** * Pin the exact set of registered providers — adding or removing a * provider must be a deliberate change to this assertion. Catches