{"record":{"id":"36d86781219b7562","repo":"passbolt/passbolt_api","slug":"the-settings-status-is-invalid","errorCode":null,"errorMessage":"The settings status is invalid.","messagePattern":"The settings status is invalid\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsActivateService.php","lineNumber":134,"sourceCode":"     * @throws \\Cake\\Http\\Exception\\NotFoundException if the settings id is not found\n     * @return \\Passbolt\\Sso\\Model\\Entity\\SsoSetting\n     */\n    protected function assertAndGetSettings(string $id, string $status): SsoSetting\n    {\n        if (!Validation::uuid($id)) {\n            throw new BadRequestException(__('The SSO setting id should be a uuid.'));\n        }\n\n        try {\n                $this->SsoSettings = TableRegistry::getTableLocator()->get('Passbolt/Sso.SsoSettings');\n            /** @var \\Passbolt\\Sso\\Model\\Entity\\SsoSetting $ssoSettings */\n            $ssoSettings = $this->SsoSettings->find()->where(['id' => $id])->firstOrFail();\n        } catch (RecordNotFoundException $exception) {\n            throw new NotFoundException(__('The SSO setting does not exist.'), 404, $exception);\n        }\n\n        if ($ssoSettings->status !== $status) {\n            throw new BadRequestException(__('The settings status is invalid.'));\n        }\n\n        return $ssoSettings;\n    }\n\n    /**\n     * @param array $data user provided data\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if status is invalid\n     * @return void\n     */\n    protected function assertActiveStatus(array $data): void\n    {\n        if (!isset($data['status']) || $data['status'] !== SsoSetting::STATUS_ACTIVE) {\n            throw new BadRequestException(__('Invalid status.'));\n        }\n    }\n}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsActivateService.php#L116-L152","documentation":"assertAndGetSettings() checks that the persisted settings row's status equals the requested status (STATUS_DRAFT for activation). If the stored status differs, a BadRequestException 'The settings status is invalid.' is thrown.","triggerScenarios":"Calling activate() on settings whose status is already 'active' (double activation), 'deleted', or otherwise not the required draft status expected by the flow.","commonSituations":"User clicks activate twice or a retry fires after the first activation succeeded; another admin activated the same draft concurrently; stale UI showing a draft that was already activated.","solutions":["Verify the settings current status via GET before activating; skip activation if already active","Create a fresh draft and activate that one instead of retrying the consumed one","Serialize the activation flow so only one admin can activate a given draft"],"exampleFix":"// before\n$service->activate($uac, $id, $data); // may double-activate\n// after\n$setting = $settingsTable->get($id);\nif ($setting->status !== SsoSetting::STATUS_DRAFT) { return; } // already handled\n$service->activate($uac, $id, $data);","handlingStrategy":"validation","validationCode":"$setting = $settingsTable->get($id); if ($setting->status !== SsoSetting::STATUS_DRAFT) { return; // already activated }","typeGuard":null,"tryCatchPattern":"try { $service->activate($uac, $id, $data); } catch (BadRequestException $e) { // status mismatch: re-fetch state and skip or restart }","preventionTips":["Check current status via GET before activating","Disable the activate button once activated","Serialize admin activation flows"],"tags":["sso","state","bad-request","passbolt"],"backgroundTag":"invalid-state-transition","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"}