Copilot commented on code in PR #13889:
URL: https://github.com/apache/cloudstack/pull/13889#discussion_r3995676311


##########
plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmd.java:
##########
@@ -151,6 +164,22 @@ public void execute() throws ServerApiException, 
ConcurrentOperationException, E
                 provider.getAuthorizeUrl(), provider.getTokenUrl(), domain);
         response.setResponseName(getCommandName());
         response.setObjectName(ApiConstants.OAUTH_PROVIDER);
+
+        List<UserOAuth2Authenticator> userOAuth2AuthenticatorPlugins = 
_oauth2mgr.listUserOAuth2AuthenticationProviders();
+        List<String> authenticatorPluginNames = new ArrayList<>();
+
+        for (UserOAuth2Authenticator authenticator : 
userOAuth2AuthenticatorPlugins) {
+            String name = authenticator.getName();
+            authenticatorPluginNames.add(name);
+        }

Review Comment:
   `listUserOAuth2AuthenticationProviders()` can return `null`: the manager 
field is nullable and its initializer explicitly guards that case at 
`OAuth2AuthManagerImpl.java:145-150`. With no authenticator plugins configured, 
this new loop throws after `registerOauthProvider` has already persisted the 
provider, turning registration into a 500 and leaving the row behind. Treat a 
null result as an empty list before iterating (or initialize the manager field 
to an empty list).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to