Open Closed

Tenant not found! There is no tenant with the tenant id or name: 00bbbd7e-953d-7c7d-3842-3a01cc9219ec #2522


User avatar
0
mert.kir created
  • ABP Framework version: v4.4.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: Tenant not found! There is no tenant with the tenant id or name: 00bbbd7e-953d-7c7d-3842-3a01cc9219ec
  • Steps to reproduce the issue:" -Login as host and delete one tenant. -When you exit the application, the _tenant value in the cookie is deleted, but since the deleted tenant information is included in the redis, the _tenant information in the cookie takes the id of the deleted tenant. Deleted tenant information should also be deleted from Redis. -Thus, api/abp/application-configuration 500 error code returns. -In order to open the page, the _tenant and .AspNetCore.Identity in the cache, abpsession information in the LocalStorage must be deleted. -Doing it like this is a workaround solution.

The same problem occurs when deleting the database and creating a migration again. Is there a solution for this abp version (v4)?


14 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @mert.kir

    You're right, it should be deleted. I've created an issue ( #11549 ) for that. It'll be included in next version (v5.2)

    This exception is right. There can be a lot of users of the deleted tenant that used the application before it's deleted and the cookie'll still exist in their browsers. In that case, this exception will occur.

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    We released v5.2 but this couldn't be shipped in v5.2 version, it'll be available very soon in the next patch version

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Solution has been merged and will be shipped in v5.2.1 very soon

  • User Avatar
    0
    mert.kir created

    Solution has been merged and will be shipped in v5.2.1 very soon

    thanks, is there this improvement in current version 5.2.1? I'm asking because I can't see it in the changelog

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Purging cache after deletion a tenant was shipped in v5.2.1.

  • User Avatar
    0
    mert.kir created

    Purging cache after deletion a tenant was shipped in v5.2.1.

    Hi, I am using abp version 5.2.2 and the error still persists. I am writing steps how to reproduce the error.

    • A tenant named Test is created by entering the host in a browser.
    • The application is entered with the created tenant.
    • Then the application is exited and the login screen is displayed.
    • Login as host from a different browser and delete the Test tenant just created.
    • When we refresh the page we just logged out of, "Tenant not found! There is no tenant with the tenant id or name: 1e46a5e6-4fd1-ee24-a5c5-3a04ac356348".
    • As a workaround, you need to clear the browser's cache. The real solution to this needs to be done.

    Can it be fixed with the first update?

  • User Avatar
    0
    alper created
    Support Team Director

    @maliming will be your point of contact for this issue

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please custom the MultiTenancyMiddlewareErrorPageBuilder of AbpAspNetCoreMultiTenancyOptions to delete the cookies.

    https://github.com/abpframework/abp/pull/13157

  • User Avatar
    0
    mert.kir created

    hi

    Please custom the MultiTenancyMiddlewareErrorPageBuilder of AbpAspNetCoreMultiTenancyOptions to delete the cookies.

    https://github.com/abpframework/abp/pull/13157

    Hello, will this development be in the next first version?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    It will be available in 6.0. but you can change it by yourself now.

  • User Avatar
    0
    mert.kir created

    It will be available in 6.0. but you can change it by yourself now.

    We have overwritten the modified code in the module file. It changes tenant information on the cookie but redirects to "tenant not found" exception page. It should redirect to main login page without any errors.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We have overwritten the modified code in the module file.

    Please share your modified code.

  • User Avatar
    0
    mert.kir created

    Hello, I added the following code to the HttpApiHostModule and IdentityServerModule files. It works when I debug the line of code. However, after setting the tenant information to null, "tenant not found!" redirects to the page.

    Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
    {
        options.MultiTenancyMiddlewareErrorPageBuilder = async (context, exception) =>
        {
            // Try to delete the tenant's cookie if it does not exist or is inactive.
            var tenantResolveResult = context.RequestServices.GetRequiredService<ITenantResolveResultAccessor>().Result;
            if (tenantResolveResult != null &&
            tenantResolveResult.AppliedResolvers.Contains(CookieTenantResolveContributor.ContributorName))
            {
                var options = context.RequestServices
                .GetRequiredService<IOptions<AbpAspNetCoreMultiTenancyOptions>>().Value;
                AbpMultiTenancyCookieHelper.SetTenantCookie(context, null, options.TenantKey);
            }
            
            context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            context.Response.ContentType = "text/html";
            
            var message = exception.Message;
            var details = exception is BusinessException businessException
            ? businessException.Details
            : string.Empty;
            
            await context.Response.WriteAsync($"<html lang=\"{CultureInfo.CurrentCulture.Name}\"><body>\r\n");
            await context.Response.WriteAsync($"<h 3>{message}</h3>{details}<br>\r\n");
            await context.Response.WriteAsync("</body></html>\r\n");
            
            // Note the 500 spaces are to work around an IE 'feature'
            await context.Response.WriteAsync(new string(' ', 500));
        };
    });
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can change these code to redirect instead of Write the HTML info.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11