Skip to content

Commit 65285bb

Browse files
committed
fix: handle mocked httpx response in webhook delivery logging
AsyncMock returns AsyncMock for status_code which can't be compared with int. Use getattr + isinstance guard for the status code check.
1 parent bf21b93 commit 65285bb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/edictum_server/notifications/webhook.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ async def _post(self, payload: dict[str, Any]) -> None:
102102
domain = urlparse(self._url).hostname or "unknown"
103103
try:
104104
resp = await self._client.post(self._url, content=body, headers=headers)
105-
if resp.status_code >= 400:
105+
status_code = getattr(resp, "status_code", None)
106+
if isinstance(status_code, int) and status_code >= 400:
106107
logger.warning(
107108
"webhook_delivery_failed",
108109
domain=domain,
109-
status_code=resp.status_code,
110+
status_code=status_code,
110111
channel=self._name,
111112
)
112113
except httpx.HTTPError:

0 commit comments

Comments
 (0)