From 85f33762d7cb7495b9aa5946284e4b6c85f5ad96 Mon Sep 17 00:00:00 2001 From: IAN MILLER <75687988+r3v5@users.noreply.github.com> Date: Thu, 4 Sep 2025 17:15:13 +0100 Subject: [PATCH] refactor(server): remove hardcoded 409 and 404 status codes in server.py using httpx constants (#3333) # What does this PR do? This PR is eliminating hardcoded status codes: `409` CONFLICT and `404` NOT_FOUND in `server.py` using `httpx` built-in constants. This implementation will follow the existing structure to improve readability, extensibility and developer experience. This is already was implemented in #3131 ## Test Plan `./scripts/unit-tests.sh` --- llama_stack/core/server/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama_stack/core/server/server.py b/llama_stack/core/server/server.py index d6dfc3435..b247a610d 100644 --- a/llama_stack/core/server/server.py +++ b/llama_stack/core/server/server.py @@ -132,9 +132,9 @@ def translate_exception(exc: Exception) -> HTTPException | RequestValidationErro }, ) elif isinstance(exc, ConflictError): - return HTTPException(status_code=409, detail=str(exc)) + return HTTPException(status_code=httpx.codes.CONFLICT, detail=str(exc)) elif isinstance(exc, ResourceNotFoundError): - return HTTPException(status_code=404, detail=str(exc)) + return HTTPException(status_code=httpx.codes.NOT_FOUND, detail=str(exc)) elif isinstance(exc, ValueError): return HTTPException(status_code=httpx.codes.BAD_REQUEST, detail=f"Invalid value: {str(exc)}") elif isinstance(exc, BadRequestError):