authentik.providers.scim.clients.exceptions

SCIM Client exceptions

 1"""SCIM Client exceptions"""
 2
 3from pydantic import ValidationError
 4from requests import Response
 5
 6from authentik.lib.sync.outgoing.exceptions import TransientSyncException
 7from authentik.providers.scim.clients.schema import SCIMError
 8
 9
10class SCIMRequestException(TransientSyncException):
11    """Exception raised when an SCIM request fails"""
12
13    _response: Response | None
14    _message: str | None
15
16    def __init__(self, response: Response | None = None, message: str | None = None) -> None:
17        super().__init__(response)
18        self._response = response
19        self._message = message or self.error_default
20
21    def detail(self) -> str:
22        """Get human readable details of this error"""
23        # requests.Response is falsy for 4xx/5xx responses, so check for None explicitly
24        if self._response is None:
25            return self._message
26        try:
27            error = SCIMError.model_validate_json(self._response.text)
28            return error.detail or self._message
29        except ValidationError:
30            pass
31        return self._response.text or self._message
32
33    def __str__(self):
34        return self.detail()
35
36    def __repr__(self):
37        return self.detail()
class SCIMRequestException(authentik.lib.sync.outgoing.exceptions.TransientSyncException):
11class SCIMRequestException(TransientSyncException):
12    """Exception raised when an SCIM request fails"""
13
14    _response: Response | None
15    _message: str | None
16
17    def __init__(self, response: Response | None = None, message: str | None = None) -> None:
18        super().__init__(response)
19        self._response = response
20        self._message = message or self.error_default
21
22    def detail(self) -> str:
23        """Get human readable details of this error"""
24        # requests.Response is falsy for 4xx/5xx responses, so check for None explicitly
25        if self._response is None:
26            return self._message
27        try:
28            error = SCIMError.model_validate_json(self._response.text)
29            return error.detail or self._message
30        except ValidationError:
31            pass
32        return self._response.text or self._message
33
34    def __str__(self):
35        return self.detail()
36
37    def __repr__(self):
38        return self.detail()

Exception raised when an SCIM request fails

SCIMRequestException( response: requests.models.Response | None = None, message: str | None = None)
17    def __init__(self, response: Response | None = None, message: str | None = None) -> None:
18        super().__init__(response)
19        self._response = response
20        self._message = message or self.error_default
def detail(self) -> str:
22    def detail(self) -> str:
23        """Get human readable details of this error"""
24        # requests.Response is falsy for 4xx/5xx responses, so check for None explicitly
25        if self._response is None:
26            return self._message
27        try:
28            error = SCIMError.model_validate_json(self._response.text)
29            return error.detail or self._message
30        except ValidationError:
31            pass
32        return self._response.text or self._message

Get human readable details of this error