bitwarden/server · error · BadRequestException
Provider must be of type Reseller in order to assign Organiz
Error message
Provider must be of type Reseller in order to assign Organizations to it.
What it means
Thrown by ProviderService.AddOrganizationsToReseller when the provider's Type is not ProviderType.Reseller. Only Reseller providers can have organizations bulk-assigned through this method. BadRequestException (HTTP 400).
Source
Thrown at bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs:482
await _organizationRepository.ReplaceAsync(organization);
if (!string.IsNullOrEmpty(organization.GatewayCustomerId))
{
await _stripeAdapter.UpdateCustomerAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
{
Email = provider.BillingEmail
});
}
await _eventService.LogProviderOrganizationEventAsync(providerOrganization, EventType.ProviderOrganization_Added);
}
public async Task AddOrganizationsToReseller(Guid providerId, IEnumerable<Guid> organizationIds)
{
var provider = await _providerRepository.GetByIdAsync(providerId);
if (provider.Type != ProviderType.Reseller)
{
throw new BadRequestException("Provider must be of type Reseller in order to assign Organizations to it.");
}
var orgIdsList = organizationIds.ToList();
var existingProviderOrganizationsCount = await _providerOrganizationRepository.GetCountByOrganizationIdsAsync(orgIdsList);
if (existingProviderOrganizationsCount > 0)
{
throw new BadRequestException("Organizations must not be assigned to any Provider.");
}
var providerOrganizationsToInsert = orgIdsList.Select(orgId => new ProviderOrganization { ProviderId = providerId, OrganizationId = orgId });
var insertedProviderOrganizations = await _providerOrganizationRepository.CreateManyAsync(providerOrganizationsToInsert);
await _eventService.LogProviderOrganizationEventsAsync(insertedProviderOrganizations.Select(ipo => (ipo, EventType.ProviderOrganization_Added, (DateTime?)null)));
}
private async Task ApplyProviderPriceRateAsync(Organization organization, Provider provider)
{
// if a provider was created before Nov 6, 2023.If true, the organization plan assigned to that provider is updated to a 2020 plan.View on GitHub (pinned to e93b962371)
Solutions
- Verify provider.Type == ProviderType.Reseller before calling AddOrganizationsToReseller.
- If the provider should be a reseller, correct the provider Type in the data/admin flow first.
- For MSP/BusinessUnit providers use AddOrganization (single) instead of AddOrganizationsToReseller.
Example fix
// before
await providerService.AddOrganizationsToReseller(providerId, orgIds);
// after
if (provider.Type != ProviderType.Reseller)
{
throw new InvalidOperationException("Use AddOrganization for non-reseller providers.");
}
await providerService.AddOrganizationsToReseller(providerId, orgIds); Defensive patterns
Strategy: type-guard
Validate before calling
if (provider.Type != ProviderType.Reseller) throw new InvalidOperationException("Not a reseller."); Type guard
static bool IsReseller(Provider p) => p.Type == ProviderType.Reseller;
Prevention
- Branch on provider.Type before choosing AddOrganization vs AddOrganizationsToReseller.
- Validate provider type at the API entry point.
When it happens
Trigger: Calling AddOrganizationsToReseller(providerId, organizationIds) against an MSP or BusinessUnit provider, or a provider whose Type field is misconfigured.
Common situations: A provider record created with the wrong type; client hardcoding the reseller-add endpoint for all provider types; a seed/test fixture that defaulted Type to Msp.
Related errors
- Organizations must not be assigned to any Provider.
- Providers cannot manage organizations with the requested pla
- You cannot remove yourself.
- Organization already belongs to a provider.
- The organization is subscribed to Secrets Manager. Please co
AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13).
Data as JSON: /api/errors/899b4b6e04dcc0b1.
Report an issue: GitHub.