{"record":{"id":"7c84094118a8953f","repo":"passbolt/passbolt_api","slug":"subscription-key-could-not-be-found-7c8409","errorCode":null,"errorMessage":"Subscription key could not be found.","messagePattern":"Subscription key could not be found\\.","errorType":"exception","errorClass":"SubscriptionRecordNotFoundException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyGetService.php","lineNumber":70,"sourceCode":"        $this->Subscriptions = $this->fetchTable('Passbolt/Subscription.Subscriptions');\n        $this->SubscriptionValidateService = new SubscriptionKeyValidateService();\n    }\n\n    /**\n     * @param \\App\\Utility\\UserAccessControl $uac user access control object\n     * @return \\Passbolt\\Subscription\\Model\\Dto\\SubscriptionKeyDto\n     */\n    public function get(UserAccessControl $uac): SubscriptionKeyDto\n    {\n        if (!$uac->isAdmin()) {\n            throw new ForbiddenException(__('Only administrators can view the subscription details.'));\n        }\n        $keyString = $this->readFromDB();\n        if (!isset($keyString)) {\n            $keyString = $this->readFromFile();\n        }\n        if (!isset($keyString) || empty($keyString)) {\n            throw new SubscriptionRecordNotFoundException();\n        }\n\n        return $this->SubscriptionValidateService->validate($keyString);\n    }\n\n    /**\n     * Try to read the key string from database (OrganizationSettings table)\n     * Try new file name first then legacy name, log warnings if issues.\n     *\n     * @return string|null\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException if subscription key is invalid\n     */\n    protected function readFromDB(): ?string\n    {\n        try {\n            return $this->Subscriptions->getOrFail()->get('value');\n        } catch (SubscriptionRecordNotFoundException $exception) {\n            Log::warning('The subscription key could not be found in the database. Falling back on files.');","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyGetService.php#L52-L88","documentation":"SubscriptionKeyGetService::get() reads the subscription key from the database (readFromDB) and falls back to the config file (readFromFile). If neither exists or the value is empty, it throws SubscriptionRecordNotFoundException. It means no valid subscription key has ever been imported or saved on this instance.","triggerScenarios":"GET subscription key when the subscriptions table has no row and no subscription key file is present, or when the stored key string is empty.","commonSituations":"Fresh Passbolt EE installs where the license was never imported; the config key file was deleted or the config/keys path is wrong; database migration wiped the subscriptions table.","solutions":["Import a valid subscription key (admin UI, CLI import command, or importFromFile)","Verify the subscription key file path configuration points to the correct file","Check the subscriptions table (and file storage) for an existing key and restore it from backup"],"exampleFix":"// before\nconst dto = await getService.get(uac); // throws if absent\n// after\ntry {\n  const dto = await getService.get(uac);\n} catch (e) {\n  if (e instanceof SubscriptionRecordNotFoundException) promptLicenseImport();\n}\n","handlingStrategy":"try-catch","validationCode":"// server-side guard before get()\n$exists = $this->SubscriptionsTable->exists([]) || file_exists($keyFilePath);","typeGuard":"null","tryCatchPattern":"try { $dto = $service->get($uac); } catch (SubscriptionRecordNotFoundException $e) { // prompt license import }","preventionTips":["Import the subscription key during instance provisioning","Back up the subscriptions table and key file","Alert on empty subscription key after upgrades"],"tags":["passbolt","subscription","missing-data"],"backgroundTag":"record-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"}