bitwarden/server · error · BadRequestException

The specified sponsored organization could not be found unde

Error message

The specified sponsored organization could not be found under the given sponsoring organization.

What it means

Thrown (HTTP 400) on the admin-initiated revoke (DELETE .../{organizationId}/{sponsoredFriendlyName}/revoke) when no sponsorship under the sponsoring org matches the given friendly name (case-insensitive OrdinalIgnoreCase comparison on non-null FriendlyName). Because the match is by friendly name, not id, a stale/renamed/already-removed sponsorship yields this error rather than 404.

Source

Thrown at src/Api/Billing/Controllers/OrganizationSponsorshipsController.cs:267

    [HttpPost("{sponsoringOrganizationId}/delete")]
    [Obsolete("This endpoint is deprecated. Use DELETE /{sponsoringOrganizationId} instead.")]
    [SelfHosted(NotSelfHostedOnly = true)]
    public async Task PostRevokeSponsorship(Guid sponsoringOrganizationId)
    {
        await RevokeSponsorship(sponsoringOrganizationId);
    }

    [Authorize("Application")]
    [Authorize<ManageUsersRequirement>]
    [HttpDelete("{organizationId}/{sponsoredFriendlyName}/revoke")]
    [SelfHosted(NotSelfHostedOnly = true)]
    public async Task AdminInitiatedRevokeSponsorshipAsync([FromRoute(Name = "organizationId")] Guid sponsoringOrgId, string sponsoredFriendlyName)
    {
        var sponsorships = await _organizationSponsorshipRepository.GetManyBySponsoringOrganizationAsync(sponsoringOrgId);
        var existingOrgSponsorship = sponsorships.FirstOrDefault(s => s.FriendlyName != null && s.FriendlyName.Equals(sponsoredFriendlyName, StringComparison.OrdinalIgnoreCase));
        if (existingOrgSponsorship == null)
        {
            throw new BadRequestException("The specified sponsored organization could not be found under the given sponsoring organization.");
        }
        await _revokeSponsorshipCommand.RevokeSponsorshipAsync(existingOrgSponsorship);
    }

    [Authorize("Application")]
    [HttpDelete("sponsored/{sponsoredOrgId}")]
    [SelfHosted(NotSelfHostedOnly = true)]
    public async Task RemoveSponsorship(Guid sponsoredOrgId)
    {

        if (!await _currentContext.OrganizationOwner(sponsoredOrgId))
        {
            throw new BadRequestException("Only the owner of an organization can remove sponsorship.");
        }

        var existingOrgSponsorship = await _organizationSponsorshipRepository
            .GetBySponsoredOrganizationIdAsync(sponsoredOrgId);

View on GitHub (pinned to e93b962371)

Solutions

  1. Fetch the current sponsorships for the org and use the exact friendly name from the live record.
  2. Trim whitespace from the friendly name before submitting.
  3. If the sponsorship is already gone, treat the outcome as success (idempotent).
Defensive patterns

Strategy: validation

Validate before calling

// Fetch live sponsorships and confirm the friendly name exists before revoking.
const list = await getSponsorships(sponsoringOrgId);
const match = list.find(s => (s.friendlyName ?? '').trim().toLowerCase() === friendlyName.trim().toLowerCase());
if (!match) { showNotFound(friendlyName); return; }

Try / catch

try {
  await adminRevoke(sponsoringOrgId, friendlyName.trim());
} catch (e) {
  if (e.isBadRequest && /could not be found/i.test(e.message)) {
    refreshSponsorshipList(); // list may be stale
  } else { throw e; }
}

Prevention

When it happens

Trigger: Wrong friendly name; the sponsorship was already revoked/removed; the friendly name was renamed; trailing whitespace or casing differences (casing is handled, whitespace is not).

Common situations: UI sponsorship list is out of sync with the server; name copied with a trailing newline/space.

Related errors


AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13). Data as JSON: /api/errors/69ed500d87f73069. Report an issue: GitHub.