{"record":{"id":"407d34d7cb76e140","repo":"bitwarden/server","slug":"unsupported-provider-type-providertype","errorCode":null,"errorMessage":"Unsupported provider type {providerType}.","messagePattern":"Unsupported provider type (.+?)\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs","lineNumber":758,"sourceCode":"                if (requestedType is not (PlanType.TeamsMonthly or PlanType.EnterpriseMonthly))\n                {\n                    throw new BadRequestException($\"Managed Service Providers cannot manage organizations with the plan type {requestedType}. Only Teams (Monthly) and Enterprise (Monthly) are allowed.\");\n                }\n                break;\n            case ProviderType.BusinessUnit:\n                if (requestedType is not (PlanType.EnterpriseMonthly or PlanType.EnterpriseAnnually))\n                {\n                    throw new BadRequestException($\"Business Unit Providers cannot manage organizations with the plan type {requestedType}. Only Enterprise (Monthly) and Enterprise (Annually) are allowed.\");\n                }\n                break;\n            case ProviderType.Reseller:\n                if (_resellerDisallowedOrganizationTypes.Contains(requestedType))\n                {\n                    throw new BadRequestException($\"Providers cannot manage organizations with the requested plan type ({requestedType}). Only Teams and Enterprise accounts are allowed.\");\n                }\n                break;\n            default:\n                throw new BadRequestException($\"Unsupported provider type {providerType}.\");\n        }\n    }\n\n    private async Task UpdateClientOrganizationsEnabledStatusAsync(Guid providerId, bool enabled)\n    {\n        var providerOrganizations = await _providerOrganizationRepository.GetManyDetailsByProviderAsync(providerId);\n\n        foreach (var providerOrganization in providerOrganizations)\n        {\n            var organization = await _organizationRepository.GetByIdAsync(providerOrganization.OrganizationId);\n            if (organization != null && organization.Enabled != enabled)\n            {\n                organization.Enabled = enabled;\n                await _organizationRepository.ReplaceAsync(organization);\n                await _organizationAbilityCacheService.UpsertOrganizationAbilityAsync(organization);\n            }\n        }\n    }","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs#L740-L776","documentation":"Thrown by ProviderService.ThrowOnInvalidPlanType in the default switch case when providerType is not one of Msp, BusinessUnit, or Reseller. This is a defensive guard: the ProviderType enum gained/lost a value, or a provider record has an out-of-range Type. BadRequestException (HTTP 400).","triggerScenarios":"A new ProviderType enum member was added that ThrowOnInvalidPlanType does not handle, or a corrupt provider record has an integer Type outside the known enum range.","commonSituations":"Code/schema/enum version drift (server newer than the licensing data, or vice versa); a manually-edited provider Type; an incomplete migration that introduced a new provider type without updating this switch.","solutions":["Add a case for the new ProviderType in ThrowOnInvalidPlanType, or migrate affected providers to a supported type.","Correct the corrupt provider.Type value in the data store.","Ensure all application tiers run a version that knows the full ProviderType enum."],"exampleFix":"// before (default throws for an unhandled new enum)\ncase ProviderType.Msp: ...\ncase ProviderType.BusinessUnit: ...\ncase ProviderType.Reseller: ...\ndefault: throw new BadRequestException($\"Unsupported provider type {providerType}.\");\n\n// after (add explicit handling for the new type)\ncase ProviderType.NewKind:\n    if (requestedType is not PlanType.EnterpriseMonthly) throw new BadRequestException(...);\n    break;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(provider.Type) || provider.Type is not (ProviderType.Msp or ProviderType.BusinessUnit or ProviderType.Reseller))\n    return BadRequest(\"Unsupported provider type.\");","typeGuard":"static bool IsKnownProviderType(ProviderType t) =>\n    t is ProviderType.Msp or ProviderType.BusinessUnit or ProviderType.Reseller;","tryCatchPattern":null,"preventionTips":["Add a switch case whenever a new ProviderType is introduced.","Keep all deployment tiers on the same enum version."],"tags":["provider","enum-versioning","data-integrity","bad-request"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}