{"record":{"id":"93c72bf78558e84d","repo":"passbolt/passbolt_api","slug":"could-not-save-the-sso-state-please-try-again-later","errorCode":null,"errorMessage":"Could not save the SSO state, please try again later.","messagePattern":"Could not save the SSO state, please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/Sso/src/Service/SsoStates/SsoStatesSetService.php","lineNumber":82,"sourceCode":"                    'deleted' => DateTime::now()->modify('+' . SsoState::getExpiryDuration()),\n                ],\n                [\n                    'accessibleFields' => [\n                        'nonce' => true,\n                        'state' => true,\n                        'type' => true,\n                        'sso_settings_id' => true,\n                        'user_id' => true,\n                        'ip' => true,\n                        'user_agent' => true,\n                        'deleted' => true,\n                    ],\n                ],\n            );\n\n            $ssoState = $ssoStatesTable->saveOrFail($ssoState);\n        } catch (CakeException $e) {\n            throw new InternalErrorException(\n                __('Could not save the SSO state, please try again later.'),\n                500,\n                $e\n            );\n        }\n\n        return $ssoState;\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":92,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Sso/src/Service/SsoStates/SsoStatesSetService.php#L64-L92","documentation":"create() wraps $ssoStatesTable->saveOrFail() in a try/catch: any CakeException during the database insert is converted to InternalErrorException so the caller never sees raw DB errors. The nonce was valid, but persistence failed.","triggerScenarios":"saveOrFail() throws — DB connection failure, unique nonce constraint violation, schema mismatch (missing sso_states table after failed migration), or datasource misconfiguration.","commonSituations":"Migrations not run after installing/upgrading the SSO plugin; database down or read-only; duplicate nonce collision on retry; permissions issue on the DB user.","solutions":["Run migrations: `ddev refresh` or `bin/cake migrations migrate` so the sso_states table exists","Check DB connectivity and credentials in config/app.php","Inspect the chained exception ($e) in the error log for the real cause","Verify the nonce is unique — regenerate the state if a retry reuses the same nonce"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"$tables = \\Cake\\ORM\\TableRegistry::getTableLocator()->get('Passbolt/Sso.SsoStates'); if (!$tables->getConnection()->query('SELECT 1')->execute()) { /* check DB before SSO flows */ }","typeGuard":null,"tryCatchPattern":"try { $state = $service->create($uac, $nonce); } catch (InternalErrorException $e) { Log::error('SSO state save failed: ' . $e->getPrevious()?->getMessage()); return $this->respondError(500, $e->getMessage()); }","preventionTips":["Run migrations after installing/upgrading the SSO plugin","Monitor DB health and connection limits","Include the previous exception in server logs for diagnosis"],"tags":["sso","database","persistence","internal-error"],"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"}