{"record":{"id":"00b90e6cfc5166b6","repo":"passbolt/passbolt_api","slug":"the-sso-setting-id-should-be-a-uuid-00b90e","errorCode":null,"errorMessage":"The SSO setting id should be a uuid.","messagePattern":"The SSO setting id should be a uuid\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsActivateService.php","lineNumber":122,"sourceCode":"            ['uac' => $uac, 'ssoSetting' => $ssoSettingEntity]\n        );\n        $this->SsoSettings->getEventManager()->dispatch($event);\n\n        // Return new updated setting\n        return (new SsoSettingsGetService())->getActiveOrFail(true);\n    }\n\n    /**\n     * @param string $id uuid\n     * @param string $status for example SsoSetting::STATUS_ACTIVE\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the settings id is not a uuid\n     * @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    /**","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsActivateService.php#L104-L140","documentation":"assertAndGetSettings() validates the SSO settings id with Cake Validation::uuid() before querying. A non-UUID string is rejected immediately with a BadRequestException, avoiding a malformed database lookup.","triggerScenarios":"Calling activate() with $id set to an empty string, a numeric database key, a slug, or any malformed identifier that is not a valid UUID v4 string.","commonSituations":"Client code confusing the draft settings id with the auth token; truncated or URL-encoded ids; using legacy integer ids from a pre-UUID schema; copy/paste dropping characters.","solutions":["Pass the settings entity UUID exactly as returned by the SSO settings creation endpoint","Validate the id client-side with a UUID regex before calling activate()","If only a token is available, fetch the settings id from the draft settings record first"],"exampleFix":"// before\n$service->activate($uac, '123', $data);\n// after\nif (!Validation::uuid($settingId)) { throw new \\InvalidArgumentException('Need a UUID'); }\n$service->activate($uac, $settingId, $data);","handlingStrategy":"validation","validationCode":"if (!Validation::uuid($id)) { throw new BadRequestException(__('The SSO setting id should be a uuid.')); }","typeGuard":"function isUuid(?string $id): bool { return is_string($id) && (bool)preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $id); }","tryCatchPattern":"try { $service->activate($uac, $id, $data); } catch (BadRequestException $e) { // reject malformed id in the controller layer }","preventionTips":["Store ids as strings and never cast to int","Validate UUIDs at the controller boundary","Check for truncation when copying ids from logs/URLs"],"tags":["sso","validation","uuid","bad-request","passbolt"],"backgroundTag":"invalid-identifier-format","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"}