~tsileo/microblog.pub#149: 
'Internal Server Error' when navigating to Notifications page.

My microblog instance was offline for a period of time due to some configuration issues in my web server software. I finally got that fixed up and I'm getting an 'Internal Server Error' message when navigating to the notifications page. Every other page appears to be working just fine. I see the following error in the uvicorn.log:

INFO:     108.251.152.189:0 - "GET /admin/notifications HTTP/1.0" 500 Internal Server Error
ERROR:    Exception in ASGI application

But I'm not sure what to look at next.

Status
RESOLVED FIXED
Submitter
~heavyrocks
Assigned to
No-one
Submitted
1 year, 9 months ago
Updated
1 year, 9 months ago
Labels
No labels applied.

~jmbwell 1 year, 9 months ago

If this might related to #142, you might try the workaround mentioned at the end of that thread. You might also look through those same logs for similar messages.

I'm experiencing this as well and have not gotten to the bottom of it.

~tsileo 1 year, 9 months ago

Hey, the logs should contain additional details after the "Exception in ASGI application", can you share it?

It should look like this:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/venv/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 404, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]

Thanks!

~heavyrocks 1 year, 9 months ago

Here is more of the log, thanks for any help.

INFO:     108.251.152.189:0 - "GET /admin/notifications HTTP/1.0" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 404, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/emge/source/microblog/./app/main.py", line 176, in __call__
    await self.app(scope, receive, send_wrapper)  # type: ignore
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/emge/source/microblog/./app/admin.py", line 749, in get_notifications
    tpl_resp = await templates.render_template(
  File "/home/emge/source/microblog/./app/templates.py", line 97, in render_template
    return _templates.TemplateResponse(
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/templating.py", line 98, in TemplateResponse
    return _TemplateResponse(
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/starlette/templating.py", line 37, in __init__
    content = template.render(context)
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "app/templates/notifications.html", line 13, in top-level template code
    {% if notif.is_new %}
  File "app/templates/layout.html", line 42, in top-level template code
    {% block content %}{% endblock %}
  File "app/templates/notifications.html", line 57, in block 'content'
    <a href="{{ url_for("admin_profile") }}?actor_id={{ notif.inbox_object.actor.ap_id }}">
  File "/home/emge/.cache/pypoetry/virtualenvs/microblogpub-mA8M5apf-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 485, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'actor'

~tsileo 1 year, 9 months ago

Thanks for the details, this is bug in the pruning method: it removed the "Move" object and the notification relies on it.

I pushed a fix, if you update, you should be able to see the notifications again.

Keep me updated, thanks!

~heavyrocks 1 year, 9 months ago

Awesome, thanks so much. I'll give that a try shortly here.

~heavyrocks 1 year, 9 months ago

That did it! Thanks again, my notifications page is back. Appreciate it.

~tsileo REPORTED FIXED 1 year, 9 months ago

Thanks!

Register here or Log in to comment, or comment via email.