~tsileo/microblog.pub#116: 
Subdomain move problem

Hey,

Remember how I moved my instance from a subdomain to the root domain and things seemed to work fine? About that...

Got a reply on one of my posts from someone who followed me on the subdomain, tried to reply back and I get an internal server error:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
   File "/app/app/admin.py", line 193, in admin_new
     mentioned_actor = await fetch_actor(db_session, tag["href"])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/app/app/actor.py", line 237, in fetch_actor
     raise ValueError("local actor should not be fetched")
ValueError: local actor should not be fetched

During handling of the above exception, another exception occurred:

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)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 269, in __call__
     await super().__call__(scope, receive, send)
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/applications.py", line 124, in __call__
     await self.middleware_stack(scope, receive, send)
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
     raise exc
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
     await self.app(scope, receive, _send)
   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)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/app/app/main.py", line 176, in __call__
     await self.app(scope, receive, send_wrapper)  # type: ignore
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/exceptions.py", line 93, in __call__
     raise exc
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/exceptions.py", line 82, in __call__
     await self.app(scope, receive, sender)
   File "/usr/local/lib/python3.11/contextlib.py", line 222, in __aexit__
     await self.gen.athrow(typ, value, traceback)
   File "/app/app/database.py", line 33, in get_db_session
     yield session
   File "/opt/venv/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
     raise e
   File "/opt/venv/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
     await self.app(scope, receive, send)
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/routing.py", line 670, in __call__
     await route.handle(scope, receive, send)
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/routing.py", line 266, in handle
     await self.app(scope, receive, send)
   File "/opt/venv/.venv/lib/python3.11/site-packages/starlette/routing.py", line 65, in app
     response = await func(request)
                ^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 227, in app
     raw_response = await run_endpoint_function(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/venv/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
     return await dependant.call(**values)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/app/app/admin.py", line 196, in admin_new
     logger.exception(f"Failed to lookup {mentioned_actor}")
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'mentioned_actor' where it is not associated with a value

Might be worth updating the documentation to emphasise not changing the domain or things could break spectacularly.

Cheers,

Kevin

Status
REPORTED
Submitter
Kevin Smith
Assigned to
No-one
Submitted
5 days ago
Updated
4 days ago
Labels
No labels applied.

Alexey Shpakovsky 5 days ago · edit

Well, to be fair, https://docs.microblog.pub/user_guide.html#profile kinda mentions that:

note that the following config items cannot be updated (without breaking federation): domain, username

Bit if you're interested, to workaround this issue, you just need to edit the app/admin.py file. On line 191, where it says:

  if tag.get("type") == "Mention" and tag["name"] != LOCAL_ACTOR.handle:

add condition to check that tag["href"] != LOCAL_ACTOR.ap_id. So this line should look like this:

  if tag.get("type") == "Mention" and tag["name"] !=

LOCAL_ACTOR.handle and tag["href"] != LOCAL_ACTOR.ap_id:

That all should go on one line, preserving indentation of that line.

p.s. I had same issue when moving my instance, too :)

Kevin Smith 4 days ago · edit

I've since killed and rebuilt the server the way I wanted it in the first place but that may be good for anyone else who wants to dig too deep.

Nothing like testing in prod.

Cheers,

Kevin

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