Skip to content

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

@mejofi

Description

@mejofi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions