Skip to content

Automate browser based workflows with AI

Add Timeout to bitwarden subprocess call so it doesn't wait forever for things that don't exist (ie TOTPs) (#703)

Kerem Yilmazfd6da6681ce0
diff --git a/skyvern/forge/sdk/services/bitwarden.py b/skyvern/forge/sdk/services/bitwarden.py
index 8bf7aa3ae..6d8fcfbf1 100644
--- a/skyvern/forge/sdk/services/bitwarden.py
+++ b/skyvern/forge/sdk/services/bitwarden.py
@@ -53,7 +53,11 @@ class BitwardenService:
if additional_env:
env.update(additional_env) # Update with any additional environment variables
- return subprocess.run(command, capture_output=True, text=True, env=env)
+ try:
+ return subprocess.run(command, capture_output=True, text=True, env=env, timeout=60)
+ except subprocess.TimeoutExpired as e:
+ LOG.error("Bitwarden command timed out after 60 seconds", stdout=e.stdout, stderr=e.stderr)
+ raise e
@staticmethod
def _extract_session_key(unlock_cmd_output: str) -> str | None:
@@ -295,9 +299,12 @@ class BitwardenService:
# The identity item may store sensitive information in custom fields or default fields
# Custom fields are prioritized over default fields
# TODO (kerem): Make this case insensitive?
- if field in identity_item["fields"]:
- sensitive_information[field] = identity_item["fields"][field]["value"]
- elif field in identity_item["identity"]:
+ for item in identity_item["fields"]:
+ if item["name"] == field:
+ sensitive_information[field] = item["value"]
+ break
+
+ if field in identity_item["identity"] and field not in sensitive_information:
sensitive_information[field] = identity_item["identity"][field]
return sensitive_information