From 4381075aa29ee47a3dcaf89d474463398383b4c5 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Thu, 14 Mar 2024 09:48:31 +0100 Subject: [PATCH] Fix typing: Use of lambda caused typing errors --- src/aleph/vm/orchestrator/supervisor.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/aleph/vm/orchestrator/supervisor.py b/src/aleph/vm/orchestrator/supervisor.py index 20452df90..7c1b8467c 100644 --- a/src/aleph/vm/orchestrator/supervisor.py +++ b/src/aleph/vm/orchestrator/supervisor.py @@ -82,6 +82,11 @@ async def allow_cors_on_endpoint(request: web.Request): ) +async def http_not_found(request: web.Request): + """Return a 404 error for unknown URLs.""" + return web.HTTPNotFound() + + app = web.Application(middlewares=[server_version_middleware]) cors = aiohttp_cors.setup(app) @@ -110,9 +115,9 @@ async def allow_cors_on_endpoint(request: web.Request): web.get("/status/check/ipv6", status_check_ipv6), web.get("/status/config", status_public_config), # Raise an HTTP Error 404 if attempting to access an unknown URL within these paths. - web.get("/about/{suffix:.*}", lambda _: web.HTTPNotFound()), - web.get("/control/{suffix:.*}", lambda _: web.HTTPNotFound()), - web.get("/status/{suffix:.*}", lambda _: web.HTTPNotFound()), + web.get("/about/{suffix:.*}", http_not_found), + web.get("/control/{suffix:.*}", http_not_found), + web.get("/status/{suffix:.*}", http_not_found), # /static is used to serve static files web.static("/static", Path(__file__).parent / "views/static"), # /vm is used to launch VMs on-demand