sesh / ready

Are you production ready?
ISC License
26 stars 4 forks source link

'ready --score' fails with TypeError if host is non-existent #40

Open mejofi opened 4 months ago

mejofi commented 4 months ago

When the host to be tested does not exist, ready returns a 'No response from' message, but if the --score flag is used, it also throws a TypeError, which is less than ideal. Example;

$ ready --score test.ur.nl
URL (no scheme): test.ur.nl, Domain (no path): test.ur.nl, Second Level Domain: ur.nl
No response from https://test.ur.nl
Traceback (most recent call last):
  File "/home/qa/.local/bin/ready", line 8, in <module>
    sys.exit(ready.cli())
             ^^^^^^^^^^^
  File "/home/qa/.local/pipx/venvs/ready-check/lib/python3.11/site-packages/ready/ready.py", line 447, in cli
    print(f"Score: {score_from_results(results)}/100")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/qa/.local/pipx/venvs/ready-check/lib/python3.11/site-packages/ready/ready.py", line 381, in score_from_results
    return 100 - 3 * len([x for x in results if not x.passed and not x.warn_on_fail])
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

It probably wouldn't be a bad idea if it could distinguish between getting no response from an domain that actually exists, and getting a NXDOMAIN on DNS lookup, which is what is happening here?