{"record":{"id":"22f025aa31de3931","repo":"passbolt/passbolt_api","slug":"subscription-key-could-not-be-found","errorCode":null,"errorMessage":"Subscription key could not be found.","messagePattern":"Subscription key could not be found\\.","errorType":"exception","errorClass":"SubscriptionRecordNotFoundException","httpStatus":null,"severity":"error","filePath":"plugins/PassboltEe/Subscription/src/Model/Table/SubscriptionsTable.php","lineNumber":137,"sourceCode":"     */\n    public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options): void\n    {\n        $data['property'] = $this->getProperty();\n        $data['property_id'] = $this->getPropertyId();\n        $data['value'] = trim($data['value'] ?? '');\n        $data['value'] = trim($data['value'], '\\'\"');\n    }\n\n    /**\n     * @return \\Cake\\Datasource\\EntityInterface|array\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionRecordNotFoundException\n     */\n    public function getOrFail(): EntityInterface|array\n    {\n        try {\n            return $this->find()->firstOrFail();\n        } catch (Exception $e) {\n            throw new SubscriptionRecordNotFoundException();\n        }\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function exists($conditions = []): bool\n    {\n        return parent::exists($conditions);\n    }\n\n    /**\n     * @param string $asciiKey Subscription key string.\n     * @param \\App\\Utility\\UserAccessControl $uac Reporting who is acting.\n     * @return string the key as original string\n     */\n    public function create(string $asciiKey, UserAccessControl $uac): string\n    {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Subscription/src/Model/Table/SubscriptionsTable.php#L119-L155","documentation":"SubscriptionsTable::getOrFail() throws SubscriptionRecordNotFoundException ('Subscription key could not be found.') when the subscriptions table contains no row at all — find()->firstOrFail() finds nothing and the catch converts any failure into this domain exception. It signals that no subscription key has ever been installed on this instance.","triggerScenarios":"Calling getOrFail() (or higher-level reads like the subscription status endpoint) on a fresh passbolt install where no subscription key was imported yet, or after the subscription row was deleted (e.g. via SubscriptionKeyDeleteService).","commonSituations":"Fresh EE deployment where the admin hasn't posted the subscription key yet; subscription deleted via DELETE /subscription; database restored without the subscriptions row; running license checks during setup before key entry.","solutions":["Install a subscription key: POST /subscription with the base64 key as an admin, or use the passbolt CLI subscription command.","Check the table is not empty: `SELECT * FROM subscriptions;` — if empty, add a valid key.","If a key was recently deleted, re-import it from the passbolt account portal."],"exampleFix":"// before: reading subscription on a fresh install fails\n$subscription = $this->Subscriptions->getOrFail();\n// after: guard for absence first\ntry {\n    $subscription = $this->Subscriptions->getOrFail();\n} catch (SubscriptionRecordNotFoundException $e) {\n    // no key installed yet — prompt admin to import one\n}","handlingStrategy":"try-catch","validationCode":"$exists = $this->Subscriptions->find()->count() > 0;\nif (!$exists) { /* no key installed — handle setup flow */ }","typeGuard":null,"tryCatchPattern":"try {\n    $subscription = $this->Subscriptions->getOrFail();\n} catch (SubscriptionRecordNotFoundException $e) {\n    // no subscription key installed — show onboarding / import UI\n}","preventionTips":["Import the subscription key as part of deployment runbooks","Check subscription presence in install/upgrade health checks","Restore the subscriptions row when restoring DB backups"],"tags":["subscription-key","record-not-found","cakephp","php"],"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-21T09:17:21.228Z"}