fix: serve legacy route aliases during cutover
Some checks failed
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / pytest-smoke (push) Failing after 2s

This commit is contained in:
tegwick 2026-08-21 17:45:25 +02:00
parent 8ab1d0c09a
commit 14befd0b50
4 changed files with 57 additions and 2 deletions

View file

@ -9,6 +9,7 @@ from uuid import uuid4
import sqlalchemy as sa
from fastapi import APIRouter, Header, HTTPException, Request, status
from fastapi.routing import APIRoute
from fastapi.responses import HTMLResponse, PlainTextResponse, RedirectResponse
from hub_core.runtime.compat_catalogs import (
@ -504,6 +505,25 @@ def create_compatibility_router() -> APIRouter:
"<p>Compatibility runtime candidate; projections are authoritative.</p>"
)
# Core Hub historically served the same compatibility operations both below
# /api/v2 and at the root. Keep the aliases as real routes (not merely
# OpenAPI aliases) so a route-group cutover cannot turn existing clients into
# 404s. The canonical /api/v2 routes remain the only schema-bearing routes;
# openapi_json adds the documented alias paths deterministically.
for route in list(router.routes):
if not isinstance(route, APIRoute) or not route.path.startswith("/api/v2/"):
continue
alias = route.path.removeprefix("/api/v2")
router.add_api_route(
alias,
route.endpoint,
methods=sorted(route.methods or []),
status_code=route.status_code,
response_class=route.response_class,
include_in_schema=False,
name=f"legacy_{route.name}",
)
return router