fix: Prevent mutation of default URL patterns list in `block_requests` by vdusek · Pull Request #1702 · apify/crawlee-python

@vdusek @claude

When url_patterns was None, the code assigned it to the module-level
_DEFAULT_BLOCK_REQUEST_URL_PATTERNS constant and then called extend()
on it, permanently mutating the shared default list. This caused
extra_url_patterns to accumulate across all subsequent calls that
used the default patterns.

Fixed by creating a copy of the list before extending it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@vdusek added t-tooling

Issues with this label are in the ownership of the tooling team.

adhoc

Ad-hoc unplanned task added during the sprint.

labels

Jan 30, 2026

@vdusek vdusek added t-tooling

Issues with this label are in the ownership of the tooling team.

adhoc

Ad-hoc unplanned task added during the sprint.

labels

Jan 30, 2026

@vdusek vdusek changed the title fix: Prevent mutation of default URL patterns list in block_requests fix: Prevent mutation of default URL patterns list in block_requests

Jan 30, 2026

Mantisus

@vdusek vdusek deleted the fix/block-requests-mutable-default branch

January 30, 2026 18:50

Mantisus pushed a commit to Mantisus/crawlee-python that referenced this pull request

Feb 9, 2026
apify#1702)

When `url_patterns` was `None`, the code assigned it to the module-level `_DEFAULT_BLOCK_REQUEST_URL_PATTERNS` constant and then called `extend()` on it, permanently mutating the shared default list. This caused `extra_url_patterns` to accumulate across all subsequent calls that used the default patterns.

Fixed by creating a copy of the list before extending it.