bitwarden/server · error · NotFoundException

Resource not found.

Error message

Resource not found.

What it means

Thrown as NotFoundException by OrganizationDomainController.Get (GET /organizations/{orgId}/domain/{id}) when GetOrganizationDomainByIdOrganizationIdAsync returns null — no custom domain row exists for the given (id, orgId) pair. Access is first gated by ValidateOrganizationAccessAsync (ManageSso + org exists). Maps to HTTP 404.

Source

Thrown at src/Api/AdminConsole/Controllers/OrganizationDomainController.cs:68

    {
        await ValidateOrganizationAccessAsync(orgId);

        var domains = await _getOrganizationDomainByOrganizationIdQuery
            .GetDomainsByOrganizationIdAsync(orgId);
        var response = domains.Select(x => new OrganizationDomainResponseModel(x)).ToList();
        return new ListResponseModel<OrganizationDomainResponseModel>(response);
    }

    [HttpGet("{orgId}/domain/{id}")]
    public async Task<OrganizationDomainResponseModel> Get(Guid orgId, Guid id)
    {
        await ValidateOrganizationAccessAsync(orgId);

        var organizationDomain = await _getOrganizationDomainByIdAndOrganizationIdQuery
            .GetOrganizationDomainByIdOrganizationIdAsync(id, orgId);
        if (organizationDomain is null)
        {
            throw new NotFoundException();
        }

        return new OrganizationDomainResponseModel(organizationDomain);
    }

    [HttpPost("{orgId}/domain")]
    public async Task<OrganizationDomainResponseModel> Post(Guid orgId,
        [FromBody] OrganizationDomainRequestModel model)
    {
        await ValidateOrganizationAccessAsync(orgId);

        var organizationDomain = new OrganizationDomain
        {
            OrganizationId = orgId,
            DomainName = model.DomainName.ToLower()
        };

        organizationDomain = await _createOrganizationDomainCommand.CreateAsync(organizationDomain);

View on GitHub (pinned to e93b962371)

Solutions

  1. List the org's domains (GET /organizations/{orgId}/domain) to find the current id.
  2. Handle 404 by clearing local state and offering to create a new domain.
  3. Confirm the id and orgId belong together.
  4. Verify both route Guids are well-formed.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the domain exists before operating on it by id
var domains = await client.GetAsync<List<OrganizationDomainResponseModel>>($"organizations/{orgId}/domain");
if (domains.All(d => d.Id != id)) throw new InvalidOperationException("Domain not found for this org.");

Try / catch

try { return await client.GetAsync<OrganizationDomainResponseModel>($"organizations/{orgId}/domain/{id}"); }
catch (ApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }

Prevention

When it happens

Trigger: GET /organizations/{orgId}/domain/{id} where the domain id does not exist, was deleted, or belongs to a different organization than orgId.

Common situations: Fetching a deleted domain; stale id cached client-side; cross-org id mix-up; a typo'd Guid in the route.

Related errors


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