{"record":{"id":"65fcd4ade75d9d42","repo":"passbolt/passbolt_api","slug":"no-active-admins-were-found","errorCode":null,"errorMessage":"No active admins were found.","messagePattern":"No active admins were found\\.","errorType":"exception","errorClass":"SubscriptionException","httpStatus":null,"severity":"error","filePath":"plugins/PassboltCe/Edition/src/Command/SubscriptionImportCommand.php","lineNumber":160,"sourceCode":"            $this->abort();\n        }\n\n        $this->success(__('The subscription key was successfully imported in the database.'), $io);\n\n        return $this->successCode();\n    }\n\n    /**\n     * @return \\App\\Utility\\UserAccessControl\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException If no active admin exists.\n     */\n    private function buildAdminUac(): UserAccessControl\n    {\n        /** @var \\App\\Model\\Table\\UsersTable $usersTable */\n        $usersTable = $this->fetchTable('Users');\n        $firstAdmin = $usersTable->findFirstAdmin();\n        if ($firstAdmin === null) {\n            throw new SubscriptionException(__('No active admins were found.'));\n        }\n\n        return new UserAccessControl(Role::ADMIN, $firstAdmin->id);\n    }\n}\n","sourceCodeStart":142,"sourceCodeEnd":166,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Edition/src/Command/SubscriptionImportCommand.php#L142-L166","documentation":"SubscriptionImportCommand::buildAdminUac fetches the first active admin via UsersTable::findFirstAdmin() to author the subscription import operation. If no active admin exists it throws SubscriptionException('No active admins were found.'). The command cannot proceed without an admin identity to act as.","triggerScenarios":"Running the subscription import command on an instance whose users table contains no active (non-deleted, non-disabled) administrator account.","commonSituations":"Fresh/migrated database without admin seeding; all admins deactivated or deleted during cleanup; running the command before completing first-run setup; restoring a backup with only regular users.","solutions":["Create or reactivate an admin account (e.g. passbolt createuser or reactivation command) before importing the subscription","Verify the users table has a user linked to the admin role with active=true and deleted=false","Run the import only after first-run setup is complete"],"exampleFix":"// before\nbin/cake passbolt subscription_import key.txt // fails with no admin\n// after\nbin/cake passbolt createuser --first-name Admin --last-name User --username admin@example.com --role admin\nbin/cake passbolt subscription_import key.txt","handlingStrategy":"validation","validationCode":"$admins = $usersTable->find('active')->matching('Roles', fn($q) => $q->where(['Roles.name' => 'admin']))->count();\nif ($admins === 0) { /* abort: seed an admin first */ }","typeGuard":"$firstAdmin = $usersTable->findFirstAdmin();\nif ($firstAdmin === null) { /* handle missing admin */ }","tryCatchPattern":"try {\n    $command->execute($args, $io);\n} catch (SubscriptionException $e) {\n    $io->error($e->getMessage()); // create an admin, then re-run\n}","preventionTips":["Seed at least one active admin during provisioning","Verify first-run setup completed before import commands","Monitor for deactivated/deleted admins in alerting"],"tags":["cli","admin","database"],"backgroundTag":"user-not-found","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}