nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: stac-utils/stac-fastapi
Pull request #827 (2025-04-17 18:06:37)

revert to custom router for mgmt routes
this https://github.com/stac-utils/stac-fastapi/pull/825/files#r2048617917 was wrong! 


Patch:
diff --git a/stac_fastapi/api/stac_fastapi/api/app.py b/stac_fastapi/api/stac_fastapi/api/app.py
index bd03b4f..08c430b 100644
--- a/stac_fastapi/api/stac_fastapi/api/app.py
+++ b/stac_fastapi/api/stac_fastapi/api/app.py
@@ -371,11 +371,13 @@ class StacApi:
     def add_health_check(self) -> None:
         """Add a health check."""
 
+        mgmt_router = APIRouter(prefix=self.app.state.router_prefix)
+
         async def ping():
             """Liveliness probe."""
             return {"message": "PONG"}
 
-        self.app.router.add_api_route(
+        mgmt_router.add_api_route(
             name="Ping",
             path="/_mgmt/ping",
             response_model=Dict,
@@ -389,10 +391,9 @@ class StacApi:
             response_class=self.response_class,
             methods=["GET"],
             endpoint=ping,
-            tags=["Liveliness/Readiness"],
         )
 
-        self.app.router.add_api_route(
+        mgmt_router.add_api_route(
             name="Health",
             path="/_mgmt/health",
             response_model=Dict,
@@ -406,8 +407,8 @@ class StacApi:
             response_class=self.response_class,
             methods=["GET"],
             endpoint=self.health_check,
-            tags=["Liveliness/Readiness"],
         )
+        self.app.include_router(mgmt_router, tags=["Liveliness/Readiness"])
 
     def add_route_dependencies(
         self, scopes: List[Scope], dependencies: List[Depends]


Test patch:
diff --git a/stac_fastapi/api/tests/test_app_prefix.py b/stac_fastapi/api/tests/test_app_prefix.py
index ea20c6c..f2289cc 100644
--- a/stac_fastapi/api/tests/test_app_prefix.py
+++ b/stac_fastapi/api/tests/test_app_prefix.py
@@ -34,6 +34,9 @@ def test_api_prefix(TestCoreClient, prefix):
     )
 
     with TestClient(api.app, base_url="http://stac.io") as client:
+        ping = client.get(f"{prefix}/_mgmt/ping")
+        assert ping.status_code == 200, ping.json() == {"message": "PONG"}
+
         landing = client.get(f"{prefix}/")
         assert landing.status_code == 200, landing.json()
Repository: stac-utils/stac-fastapi
Pull request #835 (2025-04-28 13:46:37)

improve exception and message for bbox parsing
closes https://github.com/stac-utils/stac-fastapi/issues/831


Patch:
diff --git a/CHANGES.md b/CHANGES.md
index ba305f1..10ce793 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@
 
 - avoid future deprecation for pydantic.Field and use `json_schema_extra` instead of `openapi_examples`
 - use `orjson` based JSONResponse when available
+- changed from `AssertionError` to `HTTPException` for **bbox** parsing exceptions
 
 ### Added
 
diff --git a/stac_fastapi/types/stac_fastapi/types/search.py b/stac_fastapi/types/stac_fastapi/types/search.py
index f52f453..01e6227 100644
--- a/stac_fastapi/types/stac_fastapi/types/search.py
+++ b/stac_fastapi/types/stac_fastapi/types/search.py
@@ -5,7 +5,7 @@ from datetime import datetime as dt
 from typing import Dict, List, Optional, Union
 
 import attr
-from fastapi import Query
+from fastapi import HTTPException, Query
 from pydantic import Field, PositiveInt
 from pydantic.functional_validators import AfterValidator
 from stac_pydantic.api import Search
@@ -34,8 +34,16 @@ def str2list(x: str) -> Optional[List[str]]:
 def str2bbox(x: str) -> Optional[BBox]:
     """Convert string to BBox based on , delimiter."""
     if x:
-        t = tuple(float(v) for v in x.split(","))
-        assert len(t) in [4, 6], f"BBox '{x}' must have 4 or 6 values."
+        try:
+            t = tuple(float(v) for v in x.split(","))
+        except ValueError:
+            raise HTTPException(status_code=400, detail=f"invalid bbox: {x}")
+
+        if len(t) not in (4, 6):
+            raise HTTPException(
+                status_code=400, detail=f"BBox '{x}' must have 4 or 6 values."
+            )
+
         return t
 
     return None


Test patch:
diff --git a/stac_fastapi/api/tests/test_models.py b/stac_fastapi/api/tests/test_models.py
index 032b600..2f77712 100644
--- a/stac_fastapi/api/tests/test_models.py
+++ b/stac_fastapi/api/tests/test_models.py
@@ -43,7 +43,10 @@ def test_create_get_request_model():
     model = request_model(bbox="0,0,0,1,1,1")
     assert model.bbox == (0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
 
-    with pytest.raises(AssertionError):
+    with pytest.raises(HTTPException):
+        request_model(bbox="a,b")
+
+    with pytest.raises(HTTPException):
         request_model(bbox="0,0,0,1,1")
 
     model = request_model(