onelogin / onelogin-python-sdk

36 stars 37 forks source link

client.get_users() returns nonetype sometimes #58

Closed ThePoShWolf closed 2 years ago

ThePoShWolf commented 3 years ago

This seems to be happening more and more frequently, but I have a python script running in a Github Action. Here's the relevant section:

# connect to OneLogin
olclient = OneLoginClient(
    sys.argv[1],
    sys.argv[2],
    "us"
)

users = olclient.get_users(max_results=1000)
for user in users:
    ...

And it is frequently throwing the following error:

Run python ./OneLogin/script.py "***" "***"
Traceback (most recent call last):
  File "/home/runner/work/repo/repo/./OneLogin/script.py", line 25, in <module>
    for user in users:
TypeError: 'NoneType' object is not iterable
Error: Process completed with exit code 1.

If I rerun it without any changes, it will eventually work.

How can I troubleshoot this?

pitbulk commented 3 years ago

If an action could not be completed, the method will return None.

You cant iterate None, so you are getting such error.

The best option for you is to confirm that the client.error is empty, then execute the for, otherwise print the client.error_description in order to know why the call failed.

ThePoShWolf commented 3 years ago

Oh yeah, I'm aware that none can't be iterated. Let me run a few tests and check client.error and I'll report back.

ThePoShWolf commented 2 years ago

Hehe, I obviously didn't get back to that and I no longer even work for the company that I was writing that for. Sorry about the no follow up!