bernardodemarco commented on code in PR #12938:
URL: https://github.com/apache/cloudstack/pull/12938#discussion_r3022190914
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -3827,7 +3827,11 @@ public void buildACLViewSearchCriteria(SearchCriteria<?
extends ControlledViewEn
@Override
public UserAccount getUserByApiKey(String apiKey) {
+ if (keyPair == null) {
+ return null;
+ }
ApiKeyPairVO keyPair = apiKeyPairDao.findByApiKey(apiKey);
Review Comment:
@daviftorres, the `if` guard should be placed below the
declaration/initialization of the `keyPair` variable (`ApiKeyPairVO keyPair =
apiKeyPairDao.findByApiKey(apiKey);`). Currently, the variable is referenced
before initialized, which will probably cause code compilation problems.
```suggestion
ApiKeyPairVO keyPair = apiKeyPairDao.findByApiKey(apiKey);
if (keyPair == null) {
return null;
}
```
##########
server/src/main/java/com/cloud/user/AccountManagerImpl.java:
##########
@@ -3827,7 +3827,11 @@ public void buildACLViewSearchCriteria(SearchCriteria<?
extends ControlledViewEn
@Override
public UserAccount getUserByApiKey(String apiKey) {
+ if (keyPair == null) {
+ return null;
+ }
ApiKeyPairVO keyPair = apiKeyPairDao.findByApiKey(apiKey);
+
Review Comment:
Hello, @sureshanaparti and @daviftorres
I believe that specifying the `userapikey` parameter as an empty value is
not a problem here. Considering that the `null` guard that @daviftorres is
proposing will be added to the API workflow, the return of the method
`apiKeyPairDao.findByApiKey(apiKey)` will be `null`, and as a consequence,
`getUserByApiKey` will also return `null`.
--
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]