{"record":{"id":"6eefc6e522ddbac9","repo":"bitwarden/server","slug":"resource-not-found-6eefc6","errorCode":null,"errorMessage":"Resource not found.","messagePattern":"Resource not found\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Api/SecretsManager/Controllers/ServiceAccountsController.cs","lineNumber":93,"sourceCode":"        _serviceAccountSecretsDetailsQuery = serviceAccountSecretsDetailsQuery;\n        _createServiceAccountCommand = createServiceAccountCommand;\n        _updateServiceAccountCommand = updateServiceAccountCommand;\n        _deleteServiceAccountsCommand = deleteServiceAccountsCommand;\n        _revokeAccessTokensCommand = revokeAccessTokensCommand;\n        _pricingClient = pricingClient;\n        _createAccessTokenCommand = createAccessTokenCommand;\n        _updateSecretsManagerSubscriptionCommand = updateSecretsManagerSubscriptionCommand;\n        _eventService = eventService;\n        _globalSettings = globalSettings;\n    }\n\n    [HttpGet(\"/organizations/{organizationId}/service-accounts\")]\n    public async Task<ListResponseModel<ServiceAccountSecretsDetailsResponseModel>> ListByOrganizationAsync(\n        [FromRoute] Guid organizationId, [FromQuery] bool includeAccessToSecrets = false)\n    {\n        if (!_currentContext.AccessSecretsManager(organizationId))\n        {\n            throw new NotFoundException();\n        }\n\n        var userId = _userService.GetProperUserId(User).Value;\n        var orgAdmin = await _currentContext.OrganizationAdmin(organizationId);\n        var accessClient = AccessClientHelper.ToAccessClient(_currentContext.IdentityClientType, orgAdmin);\n\n        var results =\n            await _serviceAccountSecretsDetailsQuery.GetManyByOrganizationIdAsync(organizationId, userId, accessClient,\n                includeAccessToSecrets);\n        var responses = results.Select(r => new ServiceAccountSecretsDetailsResponseModel(r));\n        return new ListResponseModel<ServiceAccountSecretsDetailsResponseModel>(responses);\n    }\n\n    [HttpGet(\"{id}\")]\n    public async Task<ServiceAccountResponseModel> GetByServiceAccountIdAsync(\n        [FromRoute] Guid id)\n    {\n        var serviceAccount = await _serviceAccountRepository.GetByIdAsync(id);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/SecretsManager/Controllers/ServiceAccountsController.cs#L75-L111","documentation":"Thrown by ListByOrganizationAsync (GET /organizations/{organizationId}/service-accounts) when _currentContext.AccessSecretsManager(organizationId) returns false. The 404 intentionally hides the existence of service accounts from callers without SM access for the org.","triggerScenarios":"GET /organizations/{organizationId}/service-accounts by a caller who does not have Secrets Manager access for the specified organization — SM not enabled on the org, or the token's claims don't include SM access for that org.","commonSituations":"Listing service accounts before SM is provisioned; using a personal API key that predates the org's SM enrollment; querying an org the user was removed from.","solutions":["Confirm Secrets Manager is enabled on the target organization.","Ensure the authenticated user or service account has SM access for that orgId.","Regenerate or refresh the access token after SM access was granted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify SM access before listing service accounts\nif (!currentContext.AccessSecretsManager(organizationId))\n{\n    return Forbid();\n}\nvar result = await serviceAccountsClient.ListByOrganizationAsync(organizationId);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call service-account endpoints for orgs where SM is confirmed enabled.","Cache the user's SM-enabled org list and validate against it.","Handle 404 on service-account endpoints by verifying SM enrollment."],"tags":["secrets-manager","authorization","access-control","service-accounts","bitwarden"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}