Skip to content

Failing pydantic validation on request_dict  #551

Closed

Description

@cadlagtrader

When running the httpx crawler on v0.3.7
My request_dict
'{"url": "XXXXXX", "unique_key": "YYYYY", "method": "GET", "headers": {}, "query_params": {}, "data": {}, "user_data": {"__crawlee": {"state": "RequestState.ERROR_HANDLER"}}, "retry_count": 1, "no_retry": false, "id": "doOfa0tGsjBwT90"}'

create the exception below when running Request.model_validate(request_dict)

user_data.__crawlee.state
  Input should be 0, 1, 2, 3, 4, 5, 6 or 7 [type=enum, input_value='RequestState.ERROR_HANDLER', input_type=str]
    For further information visit https://errors.pydantic.dev/2.9/v/enum

Activity

  1. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Sep 29, 2024
  2. janbuchar commented on Sep 29, 2024

    @janbuchar
    Collaborator

    Hello and thank you for your interest in Crawlee! Where does that request_dict come from? The state property is suspicious.

  3. cadlagtrader commented on Sep 30, 2024

    @cadlagtrader
    ContributorAuthor

    Hello - the request_dict comes from a deserialised request from my crawlee storage. There is a bug in Crawlee enum serialisation/deserialisation through Pydantic (I am using v2.9.2, compatible with crawlee pyproject constraints)

    I have modifed test_complex_user_data_serialization to highlight the issue: https://github.com/cadlagtrader/crawlee-python/blob/bug_with_pydantic/tests/unit/storages/test_request_queue.py

  4. added a commit that references this issue on Sep 30, 2024
    f496f9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working.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