Separate the stored `Request` from the crawler view of it · Issue #2302 · apify/crawlee-python · GitHub
Skip to content

Separate the stored Request from the crawler view of it #2302

Open

Description

@vdusek

Request mixes the stored record with crawler state. Crawler fields such as crawl_depth, session_id, max_retries, state, skip_navigation and enqueue_strategy live in user_data['__crawlee'] (CrawleeRequestData in _request.py). That is why user_data does not belong to the user alone (#1261). RequestOptions also accepts id, which only a storage should assign.

JS v4 split the two roles. Request is the stored record that storages read and write, and CrawlingRequest is what the crawler and handlers work with. Port the same split and use it to settle #1261.

Proposed solution

  • Request holds only what a storage persists. CrawlingRequest adds the crawler-facing accessors, and the crawler builds one from each fetched request.
  • Request construction keeps accepting the crawler options, so Request.from_url(url, label=..., max_retries=...) and request lists are unchanged; only the read side moves.
  • Remove id from RequestOptions; requests coming from a storage go through a dedicated constructor.
  • Decide whether crawler data stays under user_data['__crawlee'] for wire compatibility with JS and the Apify platform, or moves out of user_data (The user_data doesn't belong exclusively to the user #1261).

JS references

This will be a breaking change.

✍️ Drafted by Claude Code

Activity

  1. added this to the 2.0 milestone on Oct 13, 2026
  2. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    debtCode quality improvement or decrease of technical debt.
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    debtCode quality improvement or decrease of technical debt.t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions