Skip to content

[Bug]: ValueError: Deserialization of type 'Logger' is not allowed. Only allowlisted configuration and strategy types can be deserialized. #1848

@arthiondaena

Description

@arthiondaena

crawl4ai version

0.8.5

Expected Behavior

Crawl a website with BFSDeepCrawlStrategy.

Current Behavior

Docker container logs

  File "/usr/local/lib/python3.12/site-packages/slowapi/extension.py", line 734, in async_wrapper
    response = await func(*args, **kwargs)  # type: ignore
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 668, in crawl
    crawler_config = CrawlerRunConfig.load(crawl_request.crawler_config)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/crawl4ai/async_configs.py", line 1871, in load
    config = from_serializable_dict(data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/crawl4ai/async_configs.py", line 288, in from_serializable_dict
    k: from_serializable_dict(v) for k, v in data["params"].items()
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/crawl4ai/async_configs.py", line 288, in from_serializable_dict
    k: from_serializable_dict(v) for k, v in data["params"].items()
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/crawl4ai/async_configs.py", line 264, in from_serializable_dict
    raise ValueError(
ValueError: Deserialization of type 'Logger' is not allowed. Only allowlisted configuration and strategy types can be deserialized.

Is this reproducible?

Yes

Inputs Causing the Bug

The given below code snippet is generating this request json

{
  "urls": [
    "http://caw.tech"
  ],
  "browser_config": {
    "type": "BrowserConfig",
    "params": {
      "headers": {
        "type": "dict",
        "value": {
          "sec-ch-ua": "\"Chromium\";v=\"116\", \"Not_A Brand\";v=\"8\", \"Google Chrome\";v=\"116\""
        }
      }
    }
  },
  "crawler_config": {
    "type": "CrawlerRunConfig",
    "params": {
      "scraping_strategy": {
        "type": "LXMLWebScrapingStrategy",
        "params": {}
      },
      "table_extraction": {
        "type": "DefaultTableExtraction",
        "params": {}
      },
      "exclude_social_media_domains": [
        "facebook.com",
        "twitter.com",
        "x.com",
        "linkedin.com",
        "instagram.com",
        "pinterest.com",
        "tiktok.com",
        "snapchat.com",
        "reddit.com"
      ],
      "verbose": false,
      "deep_crawl_strategy": {
        "type": "BFSDeepCrawlStrategy",
        "params": {
          "max_depth": 2,
          "max_pages": 10,
          "logger": {
            "type": "Logger",
            "params": {
              "name": "crawl4ai.deep_crawling.bfs_strategy"
            }
          }
        }
      }
    }
  }
}

The request is working if I manually remove the "logger" key from "params".

Steps to Reproduce

Code snippets

async with Crawl4aiDockerClient(base_url=settings.crawl4ai_api_url) as client:
    strategy = BFSDeepCrawlStrategy(
        max_depth=2,
        include_external=False,
        max_pages=10
    )
    result = await client.crawl(
        [url],
        browser_config=BrowserConfig(headless=True),
        crawler_config=CrawlerRunConfig(cache_mode=CacheMode.BYPASS, deep_crawl_strategy=strategy, verbose=False)
    )

OS

Windows 11

Python version

3.12

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

[READY]... ✓ Connected to http://localhost:11235 
[CRAWL]... ℹ Crawling 1 URLs  
[CLOSE]... ℹ Closing client 
Crawl error: Server error 500: Server error '500 Internal Server Error' for url 'http://localhost:11235/crawl'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚙ DoneBug fix, enhancement, FR that's completed pending release🐞 BugSomething isn't working📌 Root causedidentified the root cause of bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions