{"record":{"id":"ffc883f47ac0762e","repo":"bitwarden/server","slug":"resource-not-found-ffc883","errorCode":null,"errorMessage":"Resource not found.","messagePattern":"Resource not found\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Api/AdminConsole/Controllers/OrganizationDomainController.cs","lineNumber":68,"sourceCode":"    {\n        await ValidateOrganizationAccessAsync(orgId);\n\n        var domains = await _getOrganizationDomainByOrganizationIdQuery\n            .GetDomainsByOrganizationIdAsync(orgId);\n        var response = domains.Select(x => new OrganizationDomainResponseModel(x)).ToList();\n        return new ListResponseModel<OrganizationDomainResponseModel>(response);\n    }\n\n    [HttpGet(\"{orgId}/domain/{id}\")]\n    public async Task<OrganizationDomainResponseModel> Get(Guid orgId, Guid id)\n    {\n        await ValidateOrganizationAccessAsync(orgId);\n\n        var organizationDomain = await _getOrganizationDomainByIdAndOrganizationIdQuery\n            .GetOrganizationDomainByIdOrganizationIdAsync(id, orgId);\n        if (organizationDomain is null)\n        {\n            throw new NotFoundException();\n        }\n\n        return new OrganizationDomainResponseModel(organizationDomain);\n    }\n\n    [HttpPost(\"{orgId}/domain\")]\n    public async Task<OrganizationDomainResponseModel> Post(Guid orgId,\n        [FromBody] OrganizationDomainRequestModel model)\n    {\n        await ValidateOrganizationAccessAsync(orgId);\n\n        var organizationDomain = new OrganizationDomain\n        {\n            OrganizationId = orgId,\n            DomainName = model.DomainName.ToLower()\n        };\n\n        organizationDomain = await _createOrganizationDomainCommand.CreateAsync(organizationDomain);","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Controllers/OrganizationDomainController.cs#L50-L86","documentation":"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.","triggerScenarios":"GET /organizations/{orgId}/domain/{id} where the domain id does not exist, was deleted, or belongs to a different organization than orgId.","commonSituations":"Fetching a deleted domain; stale id cached client-side; cross-org id mix-up; a typo'd Guid in the route.","solutions":["List the org's domains (GET /organizations/{orgId}/domain) to find the current id.","Handle 404 by clearing local state and offering to create a new domain.","Confirm the id and orgId belong together.","Verify both route Guids are well-formed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the domain exists before operating on it by id\nvar domains = await client.GetAsync<List<OrganizationDomainResponseModel>>($\"organizations/{orgId}/domain\");\nif (domains.All(d => d.Id != id)) throw new InvalidOperationException(\"Domain not found for this org.\");","typeGuard":null,"tryCatchPattern":"try { return await client.GetAsync<OrganizationDomainResponseModel>($\"organizations/{orgId}/domain/{id}\"); }\ncatch (ApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }","preventionTips":["List domains to find the current id rather than trusting a cached value.","Handle 404 gracefully by refreshing the list.","Confirm id and orgId are correct Guids."],"tags":["not-found","organization-domain","sso","http-404"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}