Skip to content

Share one HTTP failure helper instead of copying it per module #485

Description

@NovaCode37

#473 added the same helper to two files:

modules/cert_transparency.py   def _http_failure(result, source, status_code)
modules/wayback.py             def _http_failure(result, source, status_code)

Both map 429 and 503 to RATE_LIMITED with "try again later" and everything else to ERROR. Other modules still write that mapping inline (if r.status_code == 429: return annotate(result, RATE_LIMITED, ...)), and the wording differs in each one.

What to do:

  • Move the helper into modules/module_status.py as a public function, e.g. annotate_http_failure(result, source, status_code), and import it in both modules.
  • Delete the two private copies.
  • Add a test in tests/test_module_status.py (create it if missing) for 429, 503 and 500.

Done when there is one copy of the helper and the existing cert_transparency and wayback tests still pass unchanged. Moving other modules onto it is not part of this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

good first issueGood for newcomershacktoberfestOpen for Hacktoberfest contributionspythonPull requests that update python code

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions