Skip to content

TypeError: cannot specify both default and default_factory #640

@maniraja1122

Description

@maniraja1122

The crawler was working locallly but now on apify, we are getting this error

TypeError: cannot specify both default and default_factory

full logs:

025-10-21T17:53:59.161Z Traceback (most recent call last):
2025-10-21T17:53:59.162Z   File "<frozen runpy>", line 198, in _run_module_as_main
2025-10-21T17:53:59.163Z   File "<frozen runpy>", line 88, in _run_code
2025-10-21T17:53:59.163Z   File "/usr/src/app/src/__main__.py", line 3, in <module>
2025-10-21T17:53:59.164Z     from .main import main
2025-10-21T17:53:59.165Z   File "/usr/src/app/src/main.py", line 13, in <module>
2025-10-21T17:53:59.171Z     from apify import Actor
2025-10-21T17:53:59.171Z   File "/usr/local/lib/python3.12/site-packages/apify/__init__.py", line 4, in <module>
2025-10-21T17:53:59.172Z     from crawlee import Request
2025-10-21T17:53:59.173Z   File "/usr/local/lib/python3.12/site-packages/crawlee/__init__.py", line 3, in <module>
2025-10-21T17:53:59.181Z     from ._request import Request, RequestOptions
2025-10-21T17:53:59.182Z   File "/usr/local/lib/python3.12/site-packages/crawlee/_request.py", line 11, in <module>
2025-10-21T17:53:59.183Z     from crawlee._types import EnqueueStrategy, HttpHeaders, HttpMethod, HttpPayload, JsonSerializable
2025-10-21T17:53:59.184Z   File "/usr/local/lib/python3.12/site-packages/crawlee/_types.py", line 64, in <module>
2025-10-21T17:53:59.184Z     class HttpHeaders(RootModel, Mapping[str, str]):
2025-10-21T17:53:59.185Z   File "/usr/local/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 242, in __new__
2025-10-21T17:53:59.186Z     set_model_fields(cls, config_wrapper=config_wrapper, ns_resolver=ns_resolver)
2025-10-21T17:53:59.186Z   File "/usr/local/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 566, in set_model_fields
2025-10-21T17:53:59.187Z     fields, class_vars = collect_model_fields(cls, config_wrapper, ns_resolver, typevars_map=typevars_map)
2025-10-21T17:53:59.191Z                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-21T17:53:59.192Z   File "/usr/local/lib/python3.12/site-packages/pydantic/_internal/_fields.py", line 364, in collect_model_fields
2025-10-21T17:53:59.197Z     field_info = FieldInfo_.from_annotated_attribute(ann_type, assigned_value, _source=AnnotationSource.CLASS)
2025-10-21T17:53:59.199Z                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-21T17:53:59.199Z   File "/usr/local/lib/python3.12/site-packages/pydantic/fields.py", line 443, in from_annotated_attribute
2025-10-21T17:53:59.200Z     field_info = FieldInfo._construct(
2025-10-21T17:53:59.200Z                  ^^^^^^^^^^^^^^^^^^^^^
2025-10-21T17:53:59.201Z   File "/usr/local/lib/python3.12/site-packages/pydantic/fields.py", line 519, in _construct
2025-10-21T17:53:59.202Z     merged_field_info = cls(**merged_kwargs)
2025-10-21T17:53:59.202Z                         ^^^^^^^^^^^^^^^^^^^^
2025-10-21T17:53:59.203Z   File "/usr/local/lib/python3.12/site-packages/pydantic/fields.py", line 232, in __init__
2025-10-21T17:53:59.203Z     raise TypeError('cannot specify both default and default_factory')
2025-10-21T17:53:59.204Z TypeError: cannot specify both default and default_factory

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions