From 196a87e8f8f0ebf333eaad4b9f77dfe0bcb5b5d6 Mon Sep 17 00:00:00 2001 From: Lalit Deore Date: Fri, 10 Apr 2026 15:57:22 +0530 Subject: [PATCH 1/2] fix workflow delete and tenant creation issue due to cache --- shared.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shared.go b/shared.go index e561b725..b20b3ee0 100644 --- a/shared.go +++ b/shared.go @@ -12863,7 +12863,7 @@ func HandleCreateSubOrg(resp http.ResponseWriter, request *http.Request) { DeleteCache(ctx, fmt.Sprintf("user_%s", inneruser.Username)) DeleteCache(ctx, fmt.Sprintf("user_%s", inneruser.Id)) - DeleteCache(ctx, fmt.Sprintf("%s_childorgs", inneruser.ActiveOrg.Id)) + DeleteCache(ctx, fmt.Sprintf("%s__childorgs", inneruser.ActiveOrg.Id)) } // Delete parent org cache as well from the org region @@ -13046,7 +13046,6 @@ func HandleCreateSubOrg(resp http.ResponseWriter, request *http.Request) { Id: orgId, }) - DeleteCache(ctx, fmt.Sprintf("%s_childorgs", parentOrg.Id)) DeleteCache(ctx, fmt.Sprintf("Organizations_%s", parentOrg.Id)) err = SetOrg(ctx, *parentOrg, parentOrg.Id) @@ -13090,7 +13089,6 @@ func HandleCreateSubOrg(resp http.ResponseWriter, request *http.Request) { newOrg.Users = append(newOrg.Users, loopUser) } - DeleteCache(ctx, fmt.Sprintf("%s_childorgs", newOrg.Id)) err = SetOrg(ctx, newOrg, newOrg.Id) if err != nil { log.Printf("[WARNING] Failed setting new org %s: %s", newOrg.Id, err) @@ -32616,7 +32614,7 @@ func HandleDeleteOrg(resp http.ResponseWriter, request *http.Request) { parentOrg.ChildOrgs = newChildOrg - suborgCacheKey := fmt.Sprintf("%s_childorgs", parentOrg.Id) + suborgCacheKey := fmt.Sprintf("%s__childorgs", parentOrg.Id) DeleteCache(ctx, suborgCacheKey) DeleteCache(ctx, fmt.Sprintf("Organizations_%s", subOrg.Id)) parentOrg.SyncUsage.MultiTenant.Counter = int64(len(newChildOrg)) + 1 From c75d137dcb88a2e5deb722be8de98ebc30d3ef5f Mon Sep 17 00:00:00 2001 From: Lalit Deore Date: Fri, 10 Apr 2026 17:08:13 +0530 Subject: [PATCH 2/2] skip adding support users to other orgs --- db-connector.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db-connector.go b/db-connector.go index 6ad0e882..cc913e00 100755 --- a/db-connector.go +++ b/db-connector.go @@ -6805,7 +6805,7 @@ func fixUserOrg(ctx context.Context, user *User) *User { } } - if !found { + if !found && !user.SupportAccess { user.Orgs = append(user.Orgs, user.ActiveOrg.Id) } @@ -6843,8 +6843,11 @@ func fixUserOrg(ctx context.Context, user *User) *User { if userFound { org.Users[orgIndex] = innerUser - } else { + } else if !user.SupportAccess { org.Users = append(org.Users, innerUser) + } else { + log.Printf("[DEBUG] Skipping org.Users update for support user %s (%s) in org %s — not an official member", user.Username, user.Id, orgId) + return } err = SetOrg(ctx, *org, org.Id)