{"record":{"id":"69ed500d87f73069","repo":"bitwarden/server","slug":"the-specified-sponsored-organization-could-not-be","errorCode":null,"errorMessage":"The specified sponsored organization could not be found under the given sponsoring organization.","messagePattern":"The specified sponsored organization could not be found under the given sponsoring organization\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/Billing/Controllers/OrganizationSponsorshipsController.cs","lineNumber":267,"sourceCode":"    [HttpPost(\"{sponsoringOrganizationId}/delete\")]\n    [Obsolete(\"This endpoint is deprecated. Use DELETE /{sponsoringOrganizationId} instead.\")]\n    [SelfHosted(NotSelfHostedOnly = true)]\n    public async Task PostRevokeSponsorship(Guid sponsoringOrganizationId)\n    {\n        await RevokeSponsorship(sponsoringOrganizationId);\n    }\n\n    [Authorize(\"Application\")]\n    [Authorize<ManageUsersRequirement>]\n    [HttpDelete(\"{organizationId}/{sponsoredFriendlyName}/revoke\")]\n    [SelfHosted(NotSelfHostedOnly = true)]\n    public async Task AdminInitiatedRevokeSponsorshipAsync([FromRoute(Name = \"organizationId\")] Guid sponsoringOrgId, string sponsoredFriendlyName)\n    {\n        var sponsorships = await _organizationSponsorshipRepository.GetManyBySponsoringOrganizationAsync(sponsoringOrgId);\n        var existingOrgSponsorship = sponsorships.FirstOrDefault(s => s.FriendlyName != null && s.FriendlyName.Equals(sponsoredFriendlyName, StringComparison.OrdinalIgnoreCase));\n        if (existingOrgSponsorship == null)\n        {\n            throw new BadRequestException(\"The specified sponsored organization could not be found under the given sponsoring organization.\");\n        }\n        await _revokeSponsorshipCommand.RevokeSponsorshipAsync(existingOrgSponsorship);\n    }\n\n    [Authorize(\"Application\")]\n    [HttpDelete(\"sponsored/{sponsoredOrgId}\")]\n    [SelfHosted(NotSelfHostedOnly = true)]\n    public async Task RemoveSponsorship(Guid sponsoredOrgId)\n    {\n\n        if (!await _currentContext.OrganizationOwner(sponsoredOrgId))\n        {\n            throw new BadRequestException(\"Only the owner of an organization can remove sponsorship.\");\n        }\n\n        var existingOrgSponsorship = await _organizationSponsorshipRepository\n            .GetBySponsoredOrganizationIdAsync(sponsoredOrgId);\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/Billing/Controllers/OrganizationSponsorshipsController.cs#L249-L285","documentation":"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.","triggerScenarios":"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).","commonSituations":"UI sponsorship list is out of sync with the server; name copied with a trailing newline/space.","solutions":["Fetch the current sponsorships for the org and use the exact friendly name from the live record.","Trim whitespace from the friendly name before submitting.","If the sponsorship is already gone, treat the outcome as success (idempotent)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Fetch live sponsorships and confirm the friendly name exists before revoking.\nconst list = await getSponsorships(sponsoringOrgId);\nconst match = list.find(s => (s.friendlyName ?? '').trim().toLowerCase() === friendlyName.trim().toLowerCase());\nif (!match) { showNotFound(friendlyName); return; }","typeGuard":null,"tryCatchPattern":"try {\n  await adminRevoke(sponsoringOrgId, friendlyName.trim());\n} catch (e) {\n  if (e.isBadRequest && /could not be found/i.test(e.message)) {\n    refreshSponsorshipList(); // list may be stale\n  } else { throw e; }\n}","preventionTips":["Always source the friendly name from the live sponsorship list, not a cached value.","Trim whitespace from the friendly name before submitting.","Treat an already-absent sponsorship as an idempotent success in the UI."],"tags":["billing","sponsorship","not-found","admin"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}