Skip to content

Commit 346e522

Browse files
authored
fix: stop using UPGRADE_REQUIRED for client version check (#902)
* fix: replace UPGRADE_REQUIRED with BAD_REQUEST
1 parent 79f2e22 commit 346e522

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

diracx-routers/src/diracx/routers/factory.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,9 @@ async def dispatch(self, request: Request, call_next) -> Response:
508508
# This is not managed here.
509509

510510
raise HTTPException(
511-
status_code=HTTPStatus.UPGRADE_REQUIRED,
512-
detail=f"Client version ({client_version})"
513-
f"not recent enough (>= {self.min_client_version})."
514-
"Upgrade.",
511+
status_code=HTTPStatus.BAD_REQUEST,
512+
detail=f"Client version {client_version} is not compatible with the server. "
513+
f"Upgrade to a version >= {self.min_client_version}.",
515514
)
516515
except HTTPException as exc:
517516
# Return a JSONResponse because the HTTPException

diracx-routers/tests/test_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_min_client_version_lower_than_expected(test_client):
6262
)
6363

6464
r = test_client.get("/", headers={"DiracX-Client-Version": lower_version_than_min})
65-
assert r.status_code == HTTPStatus.UPGRADE_REQUIRED
65+
assert r.status_code == HTTPStatus.BAD_REQUEST
6666
assert str(min_client_version) in r.json()["detail"]
6767

6868

0 commit comments

Comments
 (0)