Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

feat: added 2fa token parsing logic

Saurav Pandaf3fa86ea21d6
diff --git a/.github/workflows/eval.yaml b/.github/workflows/eval.yaml
index 51addc2c8..588ffb470 100644
--- a/.github/workflows/eval.yaml
+++ b/.github/workflows/eval.yaml
@@ -253,14 +253,14 @@ jobs:
PLANNER_MODEL="${{ github.event.client_payload.script_args.planner_model }}"
RUN_ID="${{ github.event.client_payload.script_args.run_id }}"
LAMINAR_EVAL_ID="${{ github.event.client_payload.script_args.laminar_eval_id }}"
- GMAIL_2FA_TOKENS="${{ toJSON(github.event.client_payload.script_args.gmail_2fa_tokens) }}"
+ # Pass raw GitHub Actions object to Python - no parsing in bash
+ GMAIL_2FA_TOKENS_RAW='${{ github.event.client_payload.script_args.gmail_2fa_tokens }}'
# Debug Gmail 2FA tokens variable assignment
echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS assignment debug:"
echo "DEBUG: πŸ”§ Raw payload value: '${{ github.event.client_payload.script_args.gmail_2fa_tokens }}'"
- echo "DEBUG: πŸ”§ toJSON result: '${{ toJSON(github.event.client_payload.script_args.gmail_2fa_tokens) }}'"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS variable value: '$GMAIL_2FA_TOKENS'"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS length: ${#GMAIL_2FA_TOKENS}"
+ echo "DEBUG: πŸ”§ Final GMAIL_2FA_TOKENS_RAW variable: '$GMAIL_2FA_TOKENS_RAW'"
+ echo "DEBUG: πŸ”§ Variable length: ${#GMAIL_2FA_TOKENS_RAW}"
# Single task mode parameters
TASK_ID="${{ github.event.client_payload.script_args.task_id }}"
@@ -305,17 +305,17 @@ jobs:
# Add Gmail 2FA parameters
echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS conditional check:"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS value at check time: '$GMAIL_2FA_TOKENS'"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS length at check time: ${#GMAIL_2FA_TOKENS}"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS equals 'null': $([[ "$GMAIL_2FA_TOKENS" == "null" ]] && echo "true" || echo "false")"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS is empty: $([[ -z "$GMAIL_2FA_TOKENS" ]] && echo "true" || echo "false")"
- echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS is non-empty: $([[ -n "$GMAIL_2FA_TOKENS" ]] && echo "true" || echo "false")"
-
- if [[ -n "$GMAIL_2FA_TOKENS" && "$GMAIL_2FA_TOKENS" != "null" ]]; then
- echo "DEBUG: βœ… GMAIL_2FA_TOKENS conditional passed - adding tokens to command"
- CMD_ARGS+=("--gmail-2fa-tokens" "$GMAIL_2FA_TOKENS")
+ echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS_RAW value at check time: '$GMAIL_2FA_TOKENS_RAW'"
+ echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS_RAW length at check time: ${#GMAIL_2FA_TOKENS_RAW}"
+ echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS_RAW equals 'null': $([[ "$GMAIL_2FA_TOKENS_RAW" == "null" ]] && echo "true" || echo "false")"
+ echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS_RAW is empty: $([[ -z "$GMAIL_2FA_TOKENS_RAW" ]] && echo "true" || echo "false")"
+ echo "DEBUG: πŸ”§ GMAIL_2FA_TOKENS_RAW is non-empty: $([[ -n "$GMAIL_2FA_TOKENS_RAW" ]] && echo "true" || echo "false")"
+
+ if [[ -n "$GMAIL_2FA_TOKENS_RAW" && "$GMAIL_2FA_TOKENS_RAW" != "null" ]]; then
+ echo "DEBUG: βœ… GMAIL_2FA_TOKENS_RAW conditional passed - adding tokens to command"
+ CMD_ARGS+=("--gmail-2fa-tokens" "$GMAIL_2FA_TOKENS_RAW")
else
- echo "DEBUG: ❌ GMAIL_2FA_TOKENS conditional failed - tokens are empty, null, or not set, skipping"
+ echo "DEBUG: ❌ GMAIL_2FA_TOKENS_RAW conditional failed - tokens are empty, null, or not set, skipping"
fi
# Add single task mode parameters
diff --git a/eval/service.py b/eval/service.py
index 2641df270..b72f06f3f 100644
--- a/eval/service.py
+++ b/eval/service.py
@@ -2853,18 +2853,66 @@ if __name__ == '__main__':
logger.info(f'πŸ”§ Total sys.argv length: {len(sys.argv)}')
logger.info(f'πŸ”§ Arguments containing "gmail": {[arg for arg in sys.argv if "gmail" in arg.lower()]}')
- # Parse Gmail 2FA tokens dictionary
+ # Parse Gmail 2FA tokens - handle GitHub Actions raw object format
gmail_tokens_dict = None
if args.gmail_2fa_tokens:
- try:
- gmail_tokens_dict = json.loads(args.gmail_2fa_tokens)
- logger.info(f'πŸ”§ Gmail 2FA tokens received: {"YES" if gmail_tokens_dict else "NO"}')
- if gmail_tokens_dict:
- logger.info(f'πŸ”§ Gmail 2FA tokens count: {len(gmail_tokens_dict)}')
- logger.info(f'πŸ”§ Gmail 2FA users: {list(gmail_tokens_dict.keys())}')
- except json.JSONDecodeError as e:
- logger.error(f'πŸ”§ Failed to parse Gmail 2FA tokens JSON: {e}')
+ raw_tokens = args.gmail_2fa_tokens
+ logger.info(f'πŸ”§ Raw Gmail 2FA tokens received: "{raw_tokens}"')
+
+ # Check if GitHub Actions passed us something like "[object Object]" or similar
+ if raw_tokens in ['[object Object]', 'null', '', '{}']:
+ logger.info('πŸ”§ GitHub Actions passed placeholder value, no Gmail tokens available')
gmail_tokens_dict = None
+ else:
+ try:
+ # First try parsing as valid JSON (in case it's already proper JSON)
+ gmail_tokens_dict = json.loads(raw_tokens)
+ logger.info(f'πŸ”§ Successfully parsed as JSON - Gmail 2FA tokens count: {len(gmail_tokens_dict)}')
+ logger.info(f'πŸ”§ Gmail 2FA users: {list(gmail_tokens_dict.keys())}')
+ except json.JSONDecodeError:
+ # If JSON parsing fails, try to parse GitHub Actions malformed toJSON format
+ try:
+ logger.info('πŸ”§ JSON parsing failed, attempting to parse GitHub Actions malformed format...')
+
+ # Handle GitHub Actions toJSON format: { key: value, key2: value2 }
+ if raw_tokens.strip() and raw_tokens.strip() not in ['null', '{}']:
+ # Remove outer braces and parse line by line
+ content = raw_tokens.strip().strip('{}').strip()
+
+ if content:
+ tokens = {}
+ lines = [line.strip() for line in content.split('\n') if line.strip()]
+
+ for line in lines:
+ # Remove trailing comma if present
+ line = line.rstrip(',')
+
+ if ':' in line:
+ # Split on first colon only
+ key, value = line.split(':', 1)
+ key = key.strip()
+ value = value.strip()
+
+ # Store the key-value pair
+ tokens[key] = value
+
+ if tokens:
+ gmail_tokens_dict = tokens
+ logger.info('πŸ”§ Successfully parsed malformed GitHub Actions format')
+ logger.info(f'πŸ”§ Gmail 2FA tokens count: {len(gmail_tokens_dict)}')
+ logger.info(f'πŸ”§ Gmail 2FA users: {list(gmail_tokens_dict.keys())}')
+ else:
+ logger.warning('πŸ”§ No tokens found in malformed format')
+ gmail_tokens_dict = None
+ else:
+ logger.warning('πŸ”§ Empty content in malformed format')
+ gmail_tokens_dict = None
+ else:
+ logger.info('πŸ”§ Raw tokens empty or null')
+ gmail_tokens_dict = None
+ except Exception as e:
+ logger.error(f'πŸ”§ Failed to parse malformed GitHub Actions format: {type(e).__name__}: {e}')
+ gmail_tokens_dict = None
else:
logger.info('πŸ”§ Gmail 2FA tokens: None or empty')
# Run tasks and evaluate