{"record":{"id":"ec867f4867f28239","repo":"abpframework/abp","slug":"given-tenant-isn-t-available-0","errorCode":null,"errorMessage":"Given tenant isn't available: {0}","messagePattern":"Given tenant isn't available: (.+?)","errorType":"exception","errorClass":"UserFriendlyException","httpStatus":500,"severity":"error","filePath":"framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs","lineNumber":58,"sourceCode":"            var tenant = await TenantStore.FindAsync(CurrentTenant.GetId());\n            Input.Name = tenant?.Name;\n        }\n    }\n\n    public virtual async Task OnPostAsync()\n    {\n        Guid? tenantId = null;\n        if (!Input.Name.IsNullOrEmpty())\n        {\n            var tenant = await TenantStore.FindAsync(TenantNormalizer.NormalizeName(Input.Name!)!);\n            if (tenant == null)\n            {\n                throw new UserFriendlyException(L[\"GivenTenantIsNotExist\", Input.Name!]);\n            }\n\n            if (!tenant.IsActive)\n            {\n                throw new UserFriendlyException(L[\"GivenTenantIsNotAvailable\", Input.Name!]);\n            }\n\n            tenantId = tenant.Id;\n        }\n\n        AbpMultiTenancyCookieHelper.SetTenantCookie(HttpContext, tenantId, Options.TenantKey);\n    }\n\n    public class TenantInfoModel\n    {\n        [InputInfoText(\"SwitchTenantHint\")]\n        public string? Name { get; set; }\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":73,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs#L40-L73","documentation":"Thrown by TenantSwitchModal.OnPostAsync right after the tenant is found: the tenant record exists but tenant.IsActive is false, meaning it has been deactivated. ABP prevents switching the current tenant context to an inactive tenant via the localized 'GivenTenantIsNotAvailable' message.","triggerScenarios":"Posting the tenant-switch modal with a name that resolves to a tenant whose IsActive flag is false.","commonSituations":"Tenant was deactivated/suspended by an admin but still appears in a cached or stale dropdown; an automation script switches to a tenant that was recently disabled; tenant deactivated mid-session.","solutions":["Reactivate the tenant via the tenant management UI/API (set IsActive = true).","Pick a different active tenant.","Refresh the tenant list source so inactive tenants are no longer offered for switching."],"exampleFix":"// before: switch to tenant that exists but IsActive == false -> not available\n// after: activate the tenant first\nawait TenantManager.UpdateAsync(tenant.Id, x => x.IsActive = true);","handlingStrategy":"validation","validationCode":"var tenant = await tenantStore.FindAsync(normalizedName);\nif (tenant != null && !tenant.IsActive)\n{\n    // tell the user the tenant is inactive; don't attempt the switch\n}","typeGuard":"null","tryCatchPattern":"try { await OnPostAsync(); }\ncatch (UserFriendlyException ex) when (ex.Code == \"GivenTenantIsNotAvailable\")\n{ /* show localized 'tenant inactive' message */ }","preventionTips":["Filter the tenant switch list to active tenants only.","Re-check tenant state immediately before switching for long sessions.","Provide an admin path to reactivate tenants.","Surface IsActive in the tenant picker UI."],"tags":["multitenancy","validation","abp","tenant-state"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}