{"record":{"id":"30bd907097fa51ba","repo":"passbolt/passbolt_api","slug":"the-metadata-private-key-could-not-be-created-please-try","errorCode":null,"errorMessage":"The metadata private key could not be created. Please try again later.","messagePattern":"The metadata private key could not be created\\. Please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysCreateService.php","lineNumber":86,"sourceCode":"                'metadata_key_id' => true,\n                'user_id' => true,\n                'data' => true,\n                'created_by' => true,\n                'modified_by' => true,\n            ],\n        ]);\n        if (!empty($metadataPrivateKey->getErrors())) {\n            $this->handleValidationErrors($metadataPrivateKey, $metadataPrivateKeysTable);\n        }\n\n        $created = $metadataPrivateKeysTable->save($metadataPrivateKey);\n        if ($created === false) {\n            if (!empty($metadataPrivateKey->getErrors())) {\n                $this->handleValidationErrors($metadataPrivateKey, $metadataPrivateKeysTable);\n            }\n            $msg = __('The metadata private key could not be created.') . ' ';\n            $msg .= __('Please try again later.');\n            throw new InternalErrorException($msg);\n        }\n\n        return $created;\n    }\n\n    /**\n     * Handle validation or build rules failure\n     *\n     * @param \\Passbolt\\Metadata\\Model\\Entity\\MetadataPrivateKey $entity that is failing the validation\n     * @param \\Passbolt\\Metadata\\Model\\Table\\MetadataPrivateKeysTable $table table\n     * @throws \\App\\Error\\Exception\\ValidationException\n     * @return void\n     */\n    protected function handleValidationErrors(MetadataPrivateKey $entity, MetadataPrivateKeysTable $table): void\n    {\n        if (Configure::read('debug')) {\n            Log::error(json_encode($entity->getErrors()));\n        }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataPrivateKeysCreateService.php#L68-L104","documentation":"Thrown by MetadataPrivateKeysCreateService::create when saving the MetadataPrivateKey entity returns false with no validation errors recorded. It is an InternalErrorException meaning the persistence layer failed for a non-validation reason, so the user is told to retry later.","triggerScenarios":"save() on MetadataPrivateKeysTable returns false without entity errors — typically a database error (constraint, connection, lock timeout) during creation of a server or user metadata private key.","commonSituations":"Database down or connection dropped mid-request; DB constraint conflicts not surfaced as validation errors; disk full on the DB server; concurrent admin operations racing on the same metadata key.","solutions":["Retry the request after a short delay, as the message suggests","Check the database is reachable and healthy (connection, disk space, locks)","Inspect server/application logs around the failure time for the underlying DB exception","Verify the metadata key and user rows exist and no unique constraints are violated"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"catch (e) { if (e.response?.status === 500 && /could not be created/.test(e.response?.body?.message)) { await delay(1000); return retryOnce(); } throw e; }","preventionTips":["Monitor database health and connectivity","Avoid concurrent admin operations on the same metadata key","Check server logs immediately when this appears to find the chained root cause"],"tags":["http-500","database","persistence","metadata"],"backgroundTag":"database-write-failed","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"}