ibeam icon indicating copy to clipboard operation
ibeam copied to clipboard

Can not login automatically - object is not iterable

Open AndrewShear opened this issue 1 year ago • 3 comments

Describe the bug Cannot log into any account automatically either live or paper. Manually works. Selenium is returning <class 'TypeError'> 'NoneType' object is not iterable.

To Reproduce Steps to reproduce the behavior:

  1. using image voyz/ibeam:0.5.2-rc2
  2. setup environment variables:
  • IBEAM_ACCOUNT
  • IBEAM_PASSWORD
  • IBEAM_AUTHENTICATION_STRATEGY=B
  1. receiving this error:
2024/04/11 10:56:14 INFO successfully loaded credentials
2024-04-11 10:56:15,372|I| ############ Starting IBeam version 0.5.2-rc2 ############
2024-04-11 10:56:15,374|I| Secrets source: env
...
2024-04-11 10:56:15,596|I| Logging in failed
2024-04-11 10:57:06,788|I| Maintenance
2024-04-11 10:57:06,956|I| Attempt number 2
2024-04-11 10:57:07,025|I| Max request retries reached after 2 attempts. Consider increasing the retries by setting IBEAM_REQUEST_RETRIES environment variable
2024-04-11 10:57:07,025|I| NO SESSION Status(running=True, session=False, connected=False, authenticated=False, competing=False, collision=False, session_id=None, server_name=None, server_version=None, expires=None)
2024-04-11 10:57:07,026|I| Authentication strategy: "B"
2024-04-11 10:57:07,026|I| No active sessions, logging in...
2024-04-11 10:57:07,026|I| Loading auth webpage at https://localhost:5000/sso/Login?forwardTo=22&RL=1&ip2loc=on
2024-04-11 10:57:14,965|I| Gateway auth webpage loaded
2024-04-11 10:57:14,966|I| Login attempt number 1
2024-04-11 10:57:15,296|E| Error encountered during authentication 
Exception:
  File "/usr/local/lib/python3.11/threading.py", line 995, in _bootstrap
    self._bootstrap_inner()
  File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 83, in _worker
    work_item.run()
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/opt/venv/lib/python3.11/site-packages/apscheduler/executors/base.py", line 125, in run_job
    retval = job.func(*job.args, **job.kwargs)
  File "/srv/ibeam/src/gateway_client.py", line 84, in _maintenance
    success, shutdown, status = self.start_and_authenticate(request_retries=self.request_retries)
  File "/srv/ibeam/src/gateway_client.py", line 53, in start_and_authenticate
    success, shutdown, status = self.strategy_handler.try_authenticating(request_retries=request_retries)
  File "/srv/ibeam/src/handlers/strategy_handler.py", line 85, in try_authenticating
    return self._authentication_strategy_B(status, request_retries)
  File "/srv/ibeam/src/handlers/strategy_handler.py", line 140, in _authentication_strategy_B
    return self._log_in(status)
  File "/srv/ibeam/src/handlers/strategy_handler.py", line 151, in _log_in
    success, shutdown = self.login_handler.login()
  File "/srv/ibeam/src/handlers/login_handler.py", line 435, in login
    self.attempt(targets, wait_and_identify_trigger, driver)
  File "/srv/ibeam/src/handlers/login_handler.py", line 359, in attempt
    trigger, target = self.step_login(targets, wait_and_identify_trigger, driver, self.secrets_handler.account, self.secrets_handler.password, self.secrets_handler.key, self.presubmit_buffer)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/ibeam/src/handlers/login_handler.py", line 164, in step_login
    user_name_el.send_keys(account)
  File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 231, in send_keys
    Command.SEND_KEYS_TO_ELEMENT, {"text": "".join(keys_to_typing(value)), "value": keys_to_typing(value)}
                                                   ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/selenium/webdriver/common/utils.py", line 137, in keys_to_typing
    characters.extend(val)

  <class 'TypeError'> 'NoneType' object is not iterable
2024-04-11 10:57:15,296|I| Cleaning up the resources. Display: <pyvirtualdisplay.display.Display object at 0x7f728e93d610> | Driver: <selenium.webdriver.chrome.webdriver.WebDriver (session="1252f2aacb6b96ac78a3edbfd5ca734d")>
2024-04-11 10:57:15,398|I| Logging in failed

Expected behavior Expect to login automatically.

Environment IBeam version: voyz/ibeam:0.5.2-rc2 Docker image or standalone: docker image running on kubernetes Python version (standalone users only): N/A OS: EKS

Additional context I have tried running this directly with docker and on my kubernetes cluster and both do not work. I have tried the latest image as well with the 0.5.2-rc2 image.

Suggest a Fix Possibly look into if the object name has changed within the selenium lookup. Maybe look into if dev tools are working appropriately.

AndrewShear avatar Apr 11 '24 15:04 AndrewShear

Hi @AndrewShear! Thanks for trying out IBeam and for the detailed description of your issues 👍

The error you've linked indicates that there is no account specified, making the account variable a None.

Have you provided IBEAM_ACCOUNT environment variable?

Voyz avatar Apr 15 '24 03:04 Voyz

@Voyz Thanks for the reply! Yes I have these 3 variables passed:

  • IBEAM_ACCOUNT
  • IBEAM_PASSWORD
  • IBEAM_AUTHENTICATION_STRATEGY=B

I will look into this more to see if somehow somewhere the env of IBEAM_ACCOUNT isn't being set properly as I'm using kubernetes.

AndrewShear avatar Apr 15 '24 03:04 AndrewShear

Interesting! I've just pushed voyz/ibeam:0.5.2-rc3 image which should raise the following exception when the IBEAM_ACCOUNT is missing:

Account cannot be None. Specify by setting IBEAM_ACCOUNT environment variable.

Give it a try and see if you see that error pop up.

Voyz avatar Apr 15 '24 03:04 Voyz

I'm going to close this issue due to inactivity. Thanks for your contribution and please feel free to request a reopen if you'd like to continue the discussion 👍

Voyz avatar Jun 17 '24 03:06 Voyz