{"record":{"id":"04d91dd5adf52109","repo":"passbolt/passbolt_api","slug":"could-not-save-the-metadata-session-key-please-try-again","errorCode":null,"errorMessage":"Could not save the metadata session key, please try again later.","messagePattern":"Could not save the metadata session key, please try again later\\.","errorType":"exception","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataSessionKeyCreateService.php","lineNumber":59,"sourceCode":"        /** @var \\Passbolt\\Metadata\\Model\\Table\\MetadataSessionKeysTable $metadataSessionKeysTable */\n        $metadataSessionKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataSessionKeys');\n\n        $metadataSessionKey = $metadataSessionKeysTable->newEntity(\n            ['user_id' => $uac->getId(), 'data' => $data],\n            ['accessibleFields' => ['user_id' => true, 'data' => true]]\n        );\n        try {\n            /** @var \\Passbolt\\Metadata\\Model\\Entity\\MetadataSessionKey $result */\n            $result = $metadataSessionKeysTable->saveOrFail($metadataSessionKey);\n        } catch (PersistenceFailedException $e) { // @phpstan-ignore-line\n            $errors = $e->getEntity()->getErrors();\n\n            throw new CustomValidationException(\n                __('The metadata session key could not be saved.'),\n                $errors\n            );\n        } catch (Exception $e) {\n            throw new InternalErrorException(\n                __('Could not save the metadata session key, please try again later.'),\n                null,\n                $e\n            );\n        }\n\n        return $result;\n    }\n\n    /**\n     * Basic sanity check for the given data value.\n     *\n     * @param mixed $data Data to check.\n     * @return void\n     */\n    private function assertData(mixed $data): void\n    {\n        if (!is_string($data)) {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataSessionKeyCreateService.php#L41-L77","documentation":"InternalErrorException thrown when an unexpected (non-persistence) Exception escapes during metadata session key creation. It wraps the original exception and tells the caller the failure is server-side and possibly transient.","triggerScenarios":"create() hits an exception other than PersistenceFailedException — DB connection loss, driver errors, exceptions thrown in beforeSave/beforeMarshal callbacks, or serialization issues.","commonSituations":"Database temporarily unreachable; a plugin's event listener throwing; disk/resource exhaustion on the server; cross-database SQL incompatibility in a custom rule.","solutions":["Retry after a short delay; the error is often transient.","Inspect the server error log for the wrapped original exception (chained via the third constructor argument).","Verify DB connectivity and plugin/event listener health; run `ddev refresh` after upgrades.","If reproducible, debug beforeSave/beforeMarshal rules on MetadataSessionKeysTable."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (InternalErrorException $e) {\n  Log::error($e->getPrevious()?->getMessage()); // chained root cause\n  // backoff and retry once; otherwise surface to ops\n}","preventionTips":["Log the chained previous exception for root cause","Monitor database availability and health","Run `ddev refresh` / migrations after upgrades","Exercise beforeSave listeners in tests"],"tags":["internal-error","database","session-key","php"],"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"}