Skip to content

Automate browser based workflows with AI

handle NONE type in http response (#3795)

LawyZhengb15d4fc2907c
diff --git a/skyvern/core/totp.py b/skyvern/core/totp.py
index 49cf35152..36366a462 100644
--- a/skyvern/core/totp.py
+++ b/skyvern/core/totp.py
@@ -108,6 +108,8 @@ async def _get_verification_code_from_url(
totp_verification_url=url,
reason=str(e),
)
+ if not json_resp:
+ return None
return json_resp.get("verification_code", None)
diff --git a/skyvern/forge/sdk/core/aiohttp_helper.py b/skyvern/forge/sdk/core/aiohttp_helper.py
index 002a7b891..ce5d3ed89 100644
--- a/skyvern/forge/sdk/core/aiohttp_helper.py
+++ b/skyvern/forge/sdk/core/aiohttp_helper.py
@@ -137,7 +137,7 @@ async def aiohttp_post(
timeout: int = DEFAULT_REQUEST_TIMEOUT,
raise_exception: bool = True,
retry_timeout: float = 0,
-) -> dict[str, Any]:
+) -> dict[str, Any] | None:
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=timeout)) as session:
count = 0
while count <= retry:
diff --git a/skyvern/services/otp_service.py b/skyvern/services/otp_service.py
index 7f76e9e88..37d8b8d7c 100644
--- a/skyvern/services/otp_service.py
+++ b/skyvern/services/otp_service.py
@@ -142,6 +142,9 @@ async def _get_otp_value_from_url(
totp_verification_url=url,
reason=str(e),
)
+ if not json_resp:
+ return None
+
code = json_resp.get("verification_code", None)
if code:
return OTPValue(value=code, type=OTPType.TOTP)