From 094c6945f5687c7f8825f7026ee01134a25d38c5 Mon Sep 17 00:00:00 2001 From: Violet Hynes Date: Tue, 30 Aug 2022 13:53:41 -0400 Subject: [PATCH] VAULT-6433 do not return nil resp if ns is nil (#16937) * VAULT-6433 do not return nil resp if ns is nil * VAULT-6433 typo --- vault/login_mfa.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vault/login_mfa.go b/vault/login_mfa.go index ba3cd2b8b1..6c0ae5755e 100644 --- a/vault/login_mfa.go +++ b/vault/login_mfa.go @@ -1362,10 +1362,12 @@ func (b *LoginMFABackend) mfaLoginEnforcementConfigToMap(eConfig *mfa.MFAEnforce resp := make(map[string]interface{}) resp["name"] = eConfig.Name ns, err := b.namespacer.NamespaceByID(context.Background(), eConfig.NamespaceID) - if ns == nil || err != nil { + if err != nil { return nil, err } - resp["namespace_path"] = ns.Path + if ns != nil { + resp["namespace_path"] = ns.Path + } resp["namespace_id"] = eConfig.NamespaceID resp["mfa_method_ids"] = append([]string{}, eConfig.MFAMethodIDs...) resp["auth_method_accessors"] = append([]string{}, eConfig.AuthMethodAccessors...) @@ -1423,10 +1425,12 @@ func (b *MFABackend) mfaConfigToMap(mConfig *mfa.Config) (map[string]interface{} respData["name"] = mConfig.Name respData["namespace_id"] = mConfig.NamespaceID ns, err := b.namespacer.NamespaceByID(context.Background(), mConfig.NamespaceID) - if ns == nil || err != nil { + if err != nil { return nil, err } - respData["namespace_path"] = ns.Path + if ns != nil { + respData["namespace_path"] = ns.Path + } return respData, nil }