{"record":{"id":"1a1507c0dc4f7809","repo":"passbolt/passbolt_api","slug":"the-subscription-key-format-is-not-valid","errorCode":null,"errorMessage":"The subscription key format is not valid.","messagePattern":"The subscription key format is not valid\\.","errorType":"exception","errorClass":"SubscriptionFormatException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/Subscription/src/Model/Table/SubscriptionsTable.php","lineNumber":213,"sourceCode":"        } else {\n            return $this->create($asciiKey, $uac);\n        }\n    }\n\n    /**\n     * Throw Exceptions if errors were found in the validation.\n     *\n     * @param \\Passbolt\\Subscription\\Model\\Entity\\Subscription $subscription Subscription entity to be validated.\n     * @return void\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionFormatException\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionValidationException\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException\n     */\n    public function handleErrors(Subscription $subscription): void\n    {\n        $formatError = $subscription->getError('value');\n        if ($formatError) {\n            throw new SubscriptionFormatException(\n                __('The subscription key format is not valid.'),\n                $formatError\n            );\n        }\n    }\n\n    /**\n     * @return string\n     */\n    public function getProperty(): string\n    {\n        return OrganizationSetting::UUID_NAMESPACE . 'ee.subscription';\n    }\n\n    /**\n     * @return string\n     */\n    public function getPropertyId(): string","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Subscription/src/Model/Table/SubscriptionsTable.php#L195-L231","documentation":"SubscriptionsTable::handleErrors() throws SubscriptionFormatException when the Subscription entity has a validation error on the 'value' field, meaning the submitted subscription key string failed entity-level validation before any cryptographic check. The original validation messages are attached to the exception.","triggerScenarios":"Calling create() or update() with a $asciiKey that fails the Subscription entity's 'value' validation rules — e.g. not valid base64, not a parsable armored signed message, or empty — so newEntity(['value' => $asciiKey]) carries errors.","commonSituations":"Pasting a truncated or whitespace-mangled key; submitting the raw armored block instead of base64; newline corruption from copying through HTML email; CLI heredoc quoting stripping characters.","solutions":["Submit the key verbatim as a single base64 string from passbolt; check length and no internal newlines.","Sanitize input: trim and strip whitespace before createOrUpdate.","Locally validate: `echo '<key>' | base64 -d | head -1` must show '-----BEGIN PGP MESSAGE-----'.","Read the attached validation messages in the exception for the precise rule that failed."],"exampleFix":"// before\n$asciiKey = file_get_contents('key.txt'); // contains newlines\n$this->Subscriptions->createOrUpdate($uac, $asciiKey);\n// after\n$asciiKey = preg_replace('/\\s+/', '', trim(file_get_contents('key.txt')));\n$this->Subscriptions->createOrUpdate($uac, $asciiKey);","handlingStrategy":"validation","validationCode":"$clean = preg_replace('/\\s+/', '', trim($asciiKey));\nif ($clean === '' || base64_decode($clean, true) === false) {\n    throw new \\InvalidArgumentException('Subscription key must be valid base64');\n}\n$this->Subscriptions->createOrUpdate($uac, $clean);","typeGuard":null,"tryCatchPattern":"try {\n    $this->Subscriptions->createOrUpdate($uac, $asciiKey);\n} catch (SubscriptionFormatException $e) {\n    Log::error('Key format rejected: ' . json_encode($e->getErrors()));\n}","preventionTips":["Strip whitespace/newlines introduced by copy-paste or email clients","Transport keys as files or POST bodies, never through HTML email alone","Read the exception's attached validation errors to identify the failing rule"],"tags":["subscription-key","validation","cakephp","php"],"backgroundTag":"schema-validation-failed","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"}