Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing pydantic validation on request_dict #551

Open
cadlagtrader opened this issue Sep 29, 2024 · 2 comments · May be fixed by #556
Open

Failing pydantic validation on request_dict #551

cadlagtrader opened this issue Sep 29, 2024 · 2 comments · May be fixed by #556
Assignees
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@cadlagtrader
Copy link
Contributor

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
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 29, 2024
@janbuchar
Copy link
Collaborator

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

@cadlagtrader
Copy link
Contributor Author

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

@janbuchar janbuchar added the bug Something isn't working. label Sep 30, 2024
@vdusek vdusek added this to the 99th sprint - Tooling team milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants