Ensure key for map is not empty for tenant and developer cache
diff --git a/api_helper.go b/api_helper.go index 24dba22..45e99f0 100644 --- a/api_helper.go +++ b/api_helper.go
@@ -146,22 +146,24 @@ // apiKey doesnt exist then ignore adding developer fields if exists { apiKey := apiKey.(string) - devInfo := getDeveloperInfo(tenant.TenantId, apiKey) - _, exists := recordMap["api_product"] - if !exists { - recordMap["api_product"] = devInfo.ApiProduct - } - _, exists = recordMap["developer_app"] - if !exists { - recordMap["developer_app"] = devInfo.DeveloperApp - } - _, exists = recordMap["developer_email"] - if !exists { - recordMap["developer_email"] = devInfo.DeveloperEmail - } - _, exists = recordMap["developer"] - if !exists { - recordMap["developer"] = devInfo.Developer + if apiKey != "" { + devInfo := getDeveloperInfo(tenant.TenantId, apiKey) + _, exists := recordMap["api_product"] + if !exists { + recordMap["api_product"] = devInfo.ApiProduct + } + _, exists = recordMap["developer_app"] + if !exists { + recordMap["developer_app"] = devInfo.DeveloperApp + } + _, exists = recordMap["developer_email"] + if !exists { + recordMap["developer_email"] = devInfo.DeveloperEmail + } + _, exists = recordMap["developer"] + if !exists { + recordMap["developer"] = devInfo.Developer + } } } }
diff --git a/common_helper.go b/common_helper.go index 91a85a2..b3a9a5f 100644 --- a/common_helper.go +++ b/common_helper.go
@@ -38,10 +38,11 @@ row.Get("scope", &tenantId) row.Get("org", &org) row.Get("env", &env) - - tenantCache[id] = tenant{Org: org, - Env: env, - TenantId: tenantId} + if id != "" { + tenantCache[id] = tenant{Org: org, + Env: env, + TenantId: tenantId} + } } } }
diff --git a/listener.go b/listener.go index a088687..872ad80 100644 --- a/listener.go +++ b/listener.go
@@ -70,13 +70,15 @@ ele.Get("scope", &tenantid) ele.Get("org", &org) ele.Get("env", &env) - tenantCache[scopeuuid] = tenant{ - Org: org, - Env: env, - TenantId: tenantid} - log.Debugf("Refreshed local "+ - "tenantCache. Added "+ - "scope: "+"%s", scopeuuid) + if scopeuuid != "" { + tenantCache[scopeuuid] = tenant{ + Org: org, + Env: env, + TenantId: tenantid} + log.Debugf("Refreshed local "+ + "tenantCache. Added "+ + "scope: "+"%s", scopeuuid) + } } case common.Delete: rows = append(rows, payload.OldRow) @@ -87,10 +89,12 @@ for _, ele := range rows { var scopeuuid string ele.Get("id", &scopeuuid) - delete(tenantCache, scopeuuid) - log.Debugf("Refreshed local"+ - " tenantCache. Deleted"+ - " scope: %s", scopeuuid) + if scopeuuid != "" { + delete(tenantCache, scopeuuid) + log.Debugf("Refreshed local"+ + " tenantCache. Deleted"+ + " scope: %s", scopeuuid) + } } } }