Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit 79e931a

Browse files
Alena ProkharchykCraig Jellick
authored andcommitted
Agent auth: handle the case when account does not exist
1 parent 4c80926 commit 79e931a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

code/iaas/agent-instance/src/main/java/io/cattle/platform/agent/instance/serialization/AgentInstanceAuthObjectPostProcessor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717

1818
import javax.inject.Inject;
1919

20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
22+
2023
public class AgentInstanceAuthObjectPostProcessor implements ObjectTypeSerializerPostProcessor {
2124

25+
private static final Logger log = LoggerFactory.getLogger(AgentInstanceAuthObjectPostProcessor.class);
26+
2227
ObjectManager objectManager;
2328

2429
@Override
@@ -52,6 +57,10 @@ public void process(Object obj, String type, Map<String, Object> data) {
5257
// Secondary authed roles
5358
for (Long accountId : authedRoleAccountIds) {
5459
account = objectManager.loadResource(Account.class, accountId);
60+
if (account == null) {
61+
log.warn("Failed to find account by id [{}]", accountId);
62+
continue;
63+
}
5564
String scope = null;
5665
if (DataAccessor.fromDataFieldOf(account).withKey(AccountConstants.DATA_ACT_AS_RESOURCE_ACCOUNT).withDefault(false).as(Boolean.class)) {
5766
scope = "ENVIRONMENT";

0 commit comments

Comments
 (0)