better totp failure reason and error code (#3472)

This commit is contained in:
LawyZheng
2025-09-19 10:08:25 +08:00
committed by GitHub
parent a39ff77bd9
commit 82b2187583
5 changed files with 89 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
import structlog
from skyvern.config import settings
from skyvern.exceptions import NoTOTPVerificationCodeFound
from skyvern.exceptions import FailedToGetTOTPVerificationCode, NoTOTPVerificationCodeFound
from skyvern.forge import app
from skyvern.forge.sdk.core.aiohttp_helper import aiohttp_post
from skyvern.forge.sdk.core.security import generate_skyvern_signature
@@ -96,7 +96,17 @@ async def _get_verification_code_from_url(
"x-skyvern-signature": signature,
"Content-Type": "application/json",
}
json_resp = await aiohttp_post(url=url, data=request_data, headers=headers, raise_exception=False)
try:
json_resp = await aiohttp_post(url=url, data=request_data, headers=headers, raise_exception=False)
except Exception as e:
LOG.error("Failed to get verification code from url", exc_info=True)
raise FailedToGetTOTPVerificationCode(
task_id=task_id,
workflow_run_id=workflow_run_id,
workflow_id=workflow_permanent_id,
totp_verification_url=url,
reason=str(e),
)
return json_resp.get("verification_code", None)