{"record":{"id":"5078762f5e04ddf5","repo":"bitwarden/server","slug":"unknown-organization-connection-type-model-type","errorCode":null,"errorMessage":"Unknown Organization connection Type: {model.Type}","messagePattern":"Unknown Organization connection Type: (.+?)","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs","lineNumber":74,"sourceCode":"    {\n        if (!await HasPermissionAsync(model.OrganizationId, model.Type))\n        {\n            throw new BadRequestException($\"You do not have permission to create a connection of type {model.Type}.\");\n        }\n\n        if (await HasConnectionTypeAsync(model, null, model.Type))\n        {\n            throw new BadRequestException($\"The requested organization already has a connection of type {model.Type}. Only one of each connection type may exist per organization.\");\n        }\n\n        switch (model.Type)\n        {\n            case OrganizationConnectionType.CloudBillingSync:\n                return await CreateOrUpdateOrganizationConnectionAsync<BillingSyncConfig>(null, model, ValidateBillingSyncConfig);\n            case OrganizationConnectionType.Scim:\n                return await CreateOrUpdateOrganizationConnectionAsync<ScimConfig>(null, model);\n            default:\n                throw new BadRequestException($\"Unknown Organization connection Type: {model.Type}\");\n        }\n    }\n\n    [HttpPut(\"{organizationConnectionId}\")]\n    public async Task<OrganizationConnectionResponseModel> UpdateConnection(Guid organizationConnectionId, [FromBody] OrganizationConnectionRequestModel model)\n    {\n        if (model == null)\n        {\n            throw new NotFoundException();\n        }\n\n        var existingOrganizationConnection = await _organizationConnectionRepository.GetByIdOrganizationIdAsync(organizationConnectionId, model.OrganizationId);\n        if (existingOrganizationConnection == null)\n        {\n            throw new NotFoundException();\n        }\n\n        if (!await HasPermissionAsync(existingOrganizationConnection.OrganizationId, existingOrganizationConnection.Type))","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs#L56-L92","documentation":"Thrown by the default case of the Type switch in CreateConnection (POST /organizations/connections) when model.Type is neither CloudBillingSync(1) nor Scim(2). Because OrganizationConnectionType is a byte enum, ASP.NET model binding can accept raw integer values that fall outside the defined members, so an out-of-range int reaches this branch. Maps to HTTP 400.","triggerScenarios":"POST /organizations/connections with type set to 0, 3, or any integer not equal to 1 (CloudBillingSync) or 2 (Scim); a client sending a string that ASP.NET coerces to an undefined enum member; a forward-compatibility mismatch where the client targets an enum value added in a newer server version than the one deployed.","commonSituations":"Client and server version skew (client knows a new connection type the running server does not); hand-crafted JSON with a typo'd or zero-defaulted type field; an integration test using an arbitrary enum value without checking the deployed server's known set.","solutions":["Set model.Type to one of the documented values: 1 (CloudBillingSync) or 2 (Scim).","If you intended a newer connection type, upgrade the server to the version that defines it.","Validate the Type on the client against the OrganizationConnectionType enum before sending the request.","Check for typos or integer-vs-string serialization mismatches in the request payload."],"exampleFix":"// before\nvar model = new { type = 0, organizationId = orgId, config = ... };\n// after\nvar model = new { type = 2 /* Scim */, organizationId = orgId, config = ... };","handlingStrategy":"type-guard","validationCode":"var validTypes = new[] { OrganizationConnectionType.CloudBillingSync, OrganizationConnectionType.Scim };\nif (!validTypes.Contains(model.Type))\n    throw new ArgumentOutOfRangeException(nameof(model.Type), \"Type must be CloudBillingSync(1) or Scim(2).\");","typeGuard":"static bool IsKnownConnectionType(OrganizationConnectionType t) =>\n    Enum.IsDefined(typeof(OrganizationConnectionType), t) &&\n    t is OrganizationConnectionType.CloudBillingSync or OrganizationConnectionType.Scim;","tryCatchPattern":null,"preventionTips":["Validate the Type against the deployed enum before sending.","Keep client and server enum definitions in sync (shared constants or codegen).","Reject raw integer type values from untrusted input."],"tags":["enum","organization-connections","validation","http-400"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}