fix: respect user configuration for work with status codes by Mantisus · Pull Request #812 · apify/crawlee-python

@Mantisus

@Mantisus

@Mantisus

I have already discussed this with @janbuchar. This PR should not introduce any breaking changes. If additional_http_error_status_codes and ignore_http_error_status_codes are not specified, the previous behavior is preserved.

Status codes were previously discussed in PR: #498

However, we have differences with the JS version of crawlee:

Python:

  • 400-499 codes cause errors without retries

JS:

  • 400-499 codes are treated as successful
  • Exceptions:
    • 401, 403, 429 - cause errors with retries
    • 406 - causes error without retries and ignores ignoreHttpErrorStatusCodes parameter

@Mantisus Mantisus marked this pull request as ready for review

December 13, 2024 12:43

janbuchar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions, otherwise LGTM... much better!

vdusek

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last naming thing, otherwise LGTM.

@vdusek

However, we have differences with the JS version of crawlee:

Python:

400-499 codes cause errors without retries
JS:

400-499 codes are treated as successful
Exceptions:
401, 403, 429 - cause errors with retries
406 - causes error without retries and ignores ignoreHttpErrorStatusCodes parameter

Any ideas how we want to align it? I believe we do not have issue for that, correct? cc @janbuchar

@Mantisus

janbuchar

@janbuchar

However, we have differences with the JS version of crawlee:
Python:
400-499 codes cause errors without retries
JS:
400-499 codes are treated as successful
Exceptions:
401, 403, 429 - cause errors with retries
406 - causes error without retries and ignores ignoreHttpErrorStatusCodes parameter

Any ideas how we want to align it? I believe we do not have issue for that, correct? cc @janbuchar

I believe apify/crawlee#812 tracks this. I also think that what we do in this PR is the correct way to handle things. The "success on 4xx" in JS is a crutch that prevented retries on such errors, and we can do that more cleanly now (in both implementations).

How does the Python version handle 406 again? Can it be ignored via ignoreHttpErrorStatusCodes?

@Mantisus

janbuchar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing - it looks like there are no tests for this behavior - could you add some? test_http_crawler would be an appropriate place I guess.

@Mantisus

janbuchar

janbuchar