karlicoss / promnesia

Another piece of your extended mind
https://beepb00p.xyz/promnesia.html
MIT License
1.73k stars 74 forks source link

POST /visits 500 Internal Server Error #404

Closed MajesticThrust closed 1 year ago

MajesticThrust commented 1 year ago

I've been trying to get promnesia running on OS X, but once I get backend running, I get the following error on any page visit:

[INFO    2023-07-23 20:32:16 promnesia.server server.py:253] /visited https://github.com/karlicoss/promnesia
[INFO    2023-07-23 20:32:16 promnesia.server server.py:163] url: https://github.com/karlicoss/promnesia
INFO:     127.0.0.1:49927 - "POST /visits HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/fastapi/applications.py", line 289, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/fastapi/routing.py", line 273, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/fastapi/routing.py", line 192, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/promnesia/server.py", line 254, in visits
    return search_common(
           ^^^^^^^^^^^^^^
  File "/Users/*redacted*/Library/Python/3.11/lib/python/site-packages/promnesia/server.py", line 164, in search_common
    original_url = url and url.strip()
                           ^^^^^^^^^
AttributeError: 'pydantic_core._pydantic_core.Url' object has no attribute 'strip'

Happens both when I follow instructions in README.md (installing latest version with pip3), and also when running with Docker and custom docker-compose.yaml (pretty much identical to docker/docker_files/docker-compose.yaml). Version 1.2.20230515 in both cases.

Not sure what's going on there. Could't find any mention of this in any of the previous issues. But I've noticed that the project doesn't appear to have any version locking for the dependencies. Could it be some sneaky change in some package that's causing this?

adamwolf commented 1 year ago

I think this is related to #405, and was at least somewhat addressed in de891a642801a4bd5bbb85b15b40a90233179780.

MajesticThrust commented 1 year ago

Switching to 01cdfd20354a0061925014c77b3e4680509cd68a fixed the issue.

ryanwwest commented 8 months ago

I followed the instructions downloading promnesia via pip3 on macos today and I get the same error. Was the fix not propagated to the pip package? Is there a better way that I should be getting promnesia for that matter? As the Python package is also causing other issues.