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

[Bug]: Failed to get ssl certificate because it was not serialized correctly #778

Open
wakaka6 opened this issue Mar 3, 2025 · 1 comment
Assignees
Labels
🐞 Bug Something isn't working ⚙️ In-progress Issues, Features requests that are in Progress 📌 Root caused identified the root cause of bug
Milestone

Comments

@wakaka6
Copy link

wakaka6 commented Mar 3, 2025

crawl4ai version

0.4.3b3

Expected Behavior

API return ssl certification

Current Behavior

client:
Internal Server Error

server:
"POST /crawl_direct HTTP/1.1" 500 Internal Server Error

Is this reproducible?

Yes

Inputs Causing the Bug

curl -X 'POST' \
  'http://192.168.1.2:11235/crawl_direct' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "urls": "https://example.com",
  "magic": true,
  "extra": {
      "page_timeout": 30000,
      "proxy": "",
      "scan_full_page": true,
      "fetch_ssl_certificate": true,
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0"
    },
  "cache_mode": "disabled"
}'

Steps to Reproduce

Code snippets

OS

Linux

Python version

3.12

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

INFO:     192.168.1.2:56052 - "POST /crawl_direct HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/fastapi/routing.py", line 327, in app
    content = await serialize_response(
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/fastapi/routing.py", line 181, in serialize_response
    return field.serialize(
           ^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/fastapi/_compat.py", line 151, in serialize
    return self._type_adapter.dump_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/mambaforge/envs/crawl4ai/lib/python3.12/site-packages/pydantic/type_adapter.py", line 527, in dump_python
    return self.serializer.to_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'crawl4ai.ssl_certificate.SSLCertificate'>
@wakaka6 wakaka6 added 🐞 Bug Something isn't working 🩺 Needs Triage Needs attention of maintainers labels Mar 3, 2025
@aravindkarnam aravindkarnam added ⚙️ In-progress Issues, Features requests that are in Progress 📌 Root caused identified the root cause of bug and removed 🩺 Needs Triage Needs attention of maintainers labels Mar 25, 2025
@aravindkarnam aravindkarnam added this to the APR-Bug fixes milestone Apr 12, 2025
@wakaka6
Copy link
Author

wakaka6 commented Apr 12, 2025

@aravindkarnam Older versions of the server code main.py used result.dict() as the api return, but crawl4ai.ssl_certificate.SSLCertificate is an object, so there is no way to serialize it. It seems that this code has been removed in the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug Something isn't working ⚙️ In-progress Issues, Features requests that are in Progress 📌 Root caused identified the root cause of bug
Projects
None yet
Development

No branches or pull requests

2 participants