{"record":{"id":"e143260cc9e5c3c9","repo":"passbolt/passbolt_api","slug":"the-sso-setting-id-should-be-a-uuid-ssosettingsgetservice","errorCode":null,"errorMessage":"The SSO setting id should be a uuid.","messagePattern":"The SSO setting id should be a uuid\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsGetService.php","lineNumber":47,"sourceCode":"use Passbolt\\Sso\\Model\\Dto\\SsoSettingsDefaultDto;\nuse Passbolt\\Sso\\Model\\Dto\\SsoSettingsDto;\nuse Passbolt\\Sso\\Model\\Entity\\SsoSetting;\n\nclass SsoSettingsGetService\n{\n    /**\n     * Return a setting identified with its id\n     *\n     * @param string $id uuid\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if $id is not a valid uuid\n     * @throws \\Cake\\Datasource\\Exception\\RecordNotFoundException if setting cannot be found\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if there is an issue with settings data decryption\n     * @return \\Passbolt\\Sso\\Model\\Dto\\SsoSettingsDto\n     */\n    public function getByIdOrFail(string $id): SsoSettingsDto\n    {\n        if (!Validation::uuid($id)) {\n            throw new BadRequestException(__('The SSO setting id should be a uuid.'));\n        }\n\n        try {\n            return $this->getOrFail(['id' => $id], true);\n        } catch (RecordNotFoundException $exception) {\n            throw new RecordNotFoundException(__('The SSO setting does not exist.'), 404, $exception);\n        }\n    }\n\n    /**\n     * Get the currently active setting or return default setting (disabled)\n     *\n     * @param bool $withData with settings data, e.g. provider specific data\n     * @return \\Passbolt\\Sso\\Model\\Dto\\AbstractSsoSettingsDto\n     */\n    public function getActiveOrDefault(?bool $withData = false): AbstractSsoSettingsDto\n    {\n        try {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsGetService.php#L29-L65","documentation":"SsoSettingsGetService::getByIdOrFail() validates the SSO settings identifier before querying the database. If the id is not a valid UUID string it throws a BadRequestException because a non-UUID id can never match a settings record. This is an early input guard that keeps malformed identifiers from reaching the table query.","triggerScenarios":"Calling getByIdOrFail() (or the GET /sso/settings/{id} API endpoint) with an id that is not a UUID, e.g. a truncated string, numeric id, or empty string.","commonSituations":"Client code storing or passing the wrong field (e.g. provider name instead of the settings id), copy-paste errors, or an older client building URLs from unpersisted/draft data without an id.","solutions":["Check the id string being passed; it must be a 36-char UUID (e.g. 7f3a...-...). Log the value before the call.","Use the id returned by the SSO settings create/list API responses rather than constructing one.","Guard with Validation::uuid($id) before calling, or skip the call when the id is empty.","If the record was recently created, re-fetch the settings list to get a valid persisted id."],"exampleFix":"// before\n$dto = $service->getByIdOrFail($data['provider']);\n// after\nif (!Validation::uuid($data['id'])) {\n    throw new BadRequestException(__('Invalid settings id'));\n}\n$dto = $service->getByIdOrFail($data['id']);","handlingStrategy":"validation","validationCode":"if (!isset($id) || !is_string($id) || !Validation::uuid($id)) { throw new \\InvalidArgumentException('Invalid SSO settings id'); }","typeGuard":"$isValid = is_string($id) && (bool) preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $id);","tryCatchPattern":"try { $dto = $service->getByIdOrFail($id); } catch (BadRequestException $e) { // surface 400 to caller }","preventionTips":["Always use ids returned by the SSO settings API responses","Validate UUID format client-side before calling","Never construct ids manually from other fields"],"tags":["sso","uuid","bad-request","input-validation"],"backgroundTag":"invalid-argument-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"}