{"record":{"id":"c14d9034c5be5ecc","repo":"bitwarden/server","slug":"organization-not-found","errorCode":null,"errorMessage":"Organization not found.","messagePattern":"Organization not found\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Api/Billing/Controllers/LicensesController.cs","lineNumber":74,"sourceCode":"        {\n            await Task.Delay(2000);\n            throw new BadRequestException(\"Invalid license key.\");\n        }\n\n        var license = await _userService.GenerateLicenseAsync(user, null);\n        return license;\n    }\n\n    /// <summary>\n    /// Used by self-hosted installations to get an updated license file\n    /// </summary>\n    [HttpGet(\"organization/{id}\")]\n    public async Task<OrganizationLicense> OrganizationSync(string id, [FromBody] SelfHostedOrganizationLicenseRequestModel model)\n    {\n        var organization = await _organizationRepository.GetByIdAsync(new Guid(id));\n        if (organization == null)\n        {\n            throw new NotFoundException(\"Organization not found.\");\n        }\n\n        if (!organization.LicenseKey.Equals(model.LicenseKey))\n        {\n            await Task.Delay(2000);\n            throw new BadRequestException(\"Invalid license key.\");\n        }\n\n        if (!await _validateBillingSyncKeyCommand.ValidateBillingSyncKeyAsync(organization, model.BillingSyncKey))\n        {\n            throw new BadRequestException(\"Invalid Billing Sync Key\");\n        }\n\n        var license = await _getCloudOrganizationLicenseQuery.GetLicenseAsync(organization, _currentContext.InstallationId.Value);\n        return license;\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/Billing/Controllers/LicensesController.cs#L56-L92","documentation":"Thrown (HTTP 404) by GET /licenses/organization/{id} when _organizationRepository.GetByIdAsync(new Guid(id)) returns null — i.e. no organization exists for that id. A malformed id that cannot parse to a Guid would throw earlier at new Guid(id).","triggerScenarios":"Wrong organization id; the organization was deleted; pointing at the wrong environment (e.g. cloud id against a different cloud region).","commonSituations":"Stale org id copied into configuration; org deleted between config and call; wrong environment.","solutions":["Verify the organization id in the cloud admin / organization settings.","Ensure you are calling the correct environment/region for that org id.","Confirm the id is a well-formed Guid before submitting."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the id is a well-formed Guid and the target environment is correct before calling.\nconst GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!GUID.test(orgId)) throw new Error('Malformed organization id');","typeGuard":null,"tryCatchPattern":"try {\n  const lic = await getOrgLicense(orgId, body);\n} catch (e) {\n  if (e.status === 404) { showOrgNotFoundError(orgId); return; }\n  throw e;\n}","preventionTips":["Source org ids from live cloud settings, not stale notes.","Verify the environment/region matches the org id before calling.","Validate Guid format client-side to avoid malformed-id exceptions."],"tags":["billing","license","not-found","organization","http-404"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}