bitwarden/server · error · BadRequestException
Unknown Organization connection Type: {type}
Error message
Unknown Organization connection Type: {type} What it means
Thrown by the default case of the type switch in GetConnection (GET /organizations/connections/{organizationId}/{type}) when the route type is neither CloudBillingSync(1) nor Scim(2). The type comes from the route segment which binds to the OrganizationConnectionType enum; out-of-range integers reach the default branch. Maps to HTTP 400.
Source
Thrown at src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs:140
{
throw new BadRequestException($"You do not have permission to retrieve a connection of type {type}.");
}
var connections = await GetConnectionsAsync(organizationId, type);
var connection = connections.FirstOrDefault(c => c.Type == type);
switch (type)
{
case OrganizationConnectionType.CloudBillingSync:
if (!_globalSettings.SelfHosted)
{
throw new BadRequestException($"Cannot get a {type} connection outside of a self-hosted instance.");
}
return new OrganizationConnectionResponseModel(connection, typeof(BillingSyncConfig));
case OrganizationConnectionType.Scim:
return new OrganizationConnectionResponseModel(connection, typeof(ScimConfig));
default:
throw new BadRequestException($"Unknown Organization connection Type: {type}");
}
}
[HttpDelete("{organizationConnectionId}")]
public async Task DeleteConnection(Guid organizationConnectionId)
{
var connection = await _organizationConnectionRepository.GetByIdAsync(organizationConnectionId);
if (connection == null)
{
throw new NotFoundException();
}
if (!await HasPermissionAsync(connection.OrganizationId, connection.Type))
{
throw new BadRequestException($"You do not have permission to remove this connection of type {connection.Type}.");
}
View on GitHub (pinned to e93b962371)
Solutions
- Use type = 1 (CloudBillingSync) or 2 (Scim) in the route.
- If a newer type was expected, deploy a server version that defines it.
- Validate the type segment client-side before issuing the GET.
- Check for integer-vs-name routing mismatches.
Example fix
// before
GET /organizations/connections/{orgId}/0
// after
GET /organizations/connections/{orgId}/2 Defensive patterns
Strategy: type-guard
Validate before calling
if (!Enum.IsDefined(typeof(OrganizationConnectionType), type) ||
type is not (OrganizationConnectionType.CloudBillingSync or OrganizationConnectionType.Scim))
throw new ArgumentOutOfRangeException(nameof(type), "Type must be 1 (CloudBillingSync) or 2 (Scim)."); Type guard
static bool IsKnownConnectionType(OrganizationConnectionType t) =>
t is OrganizationConnectionType.CloudBillingSync or OrganizationConnectionType.Scim; Prevention
- Validate the route type segment before issuing the GET.
- Use named enum values, not magic integers, in URLs.
- Keep client/server enum versions aligned.
When it happens
Trigger: GET /organizations/connections/{orgId}/{type} with type = 0, 3, or any integer outside {1,2} in the route.
Common situations: Client/server version skew; a hand-typed URL with a wrong segment; an integration test using an arbitrary enum value.
Related errors
- Unknown Organization connection Type: {model.Type}
- The requested organization already has a connection of type
- The connection type cannot be changed.
- ExternalId cannot exceed 300 characters.
- ExternalId cannot exceed 300 characters.
AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13).
Data as JSON: /api/errors/35f5443b67b7da5e.
Report an issue: GitHub.