sophos / PS.Machine_Health

This will create a health report for every machines in an MSP/EDB/Single Sophos Central console
GNU General Public License v3.0
9 stars 4 forks source link

KeyError: 'capabilities' #2

Closed cherdt closed 2 years ago

cherdt commented 2 years ago

I encountered the following error running this script:

Traceback (most recent call last):
  File "Sophos_Central_Health.py", line 654, in <module>
    total_machines = get_all_computers(sub_estate['id'], f"{'https://api-'}{sub_estate['dataRegion']}{'.central.sophos.com/endpoint/v1'}",
  File "Sophos_Central_Health.py", line 285, in get_all_computers
    if len(all_computers['capabilities']) != 0:
KeyError: 'capabilities'

I was able to fix this by changing line 285

from:

if len(all_computers['capabilities']) != 0:

to:

if 'capabilities' in all_computers and len(all_computers['capabilities']) != 0:
sophosukps commented 2 years ago

Hi Chris,

Thanks for the feedback and sorry you hit this issue. Could you email me on the this account so we can discuss this further? I am interested to find out more about why this failed on your console.

Best wishes

Michael

cherdt commented 2 years ago

Thanks! It was a minor problem, but I wanted to let someone know in case this script is used frequently.

I can share the client ID and the specific sub estate where it produced the error. I don't see a way to reply without it posting here publicly though. You can reach me at my github username @ gmail and I can send you details.

sophosukps commented 2 years ago

This has been fixed