Skip to content

Commit 1a37247

Browse files
fix: issue 603 [Unexpected error when registering a gateway with the same name.] (#607)
* fix: show proper error on gateway register and added hot reload in gunicorn * Remove hot reload from run-gunicorn Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
1 parent 41a08b7 commit 1a37247

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

mcpgateway/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
ToolUpdate,
9494
)
9595
from mcpgateway.services.completion_service import CompletionService
96-
from mcpgateway.services.gateway_service import GatewayConnectionError, GatewayService
96+
from mcpgateway.services.gateway_service import GatewayConnectionError, GatewayService, GatewayNameConflictError
9797
from mcpgateway.services.logging_service import LoggingService
9898
from mcpgateway.services.prompt_service import (
9999
PromptError,
@@ -1808,6 +1808,8 @@ async def register_gateway(
18081808
return JSONResponse(content={"message": "Unable to connect to gateway"}, status_code=502)
18091809
if isinstance(ex, ValueError):
18101810
return JSONResponse(content={"message": "Unable to process input"}, status_code=400)
1811+
if isinstance(ex, GatewayNameConflictError):
1812+
return JSONResponse(content={"message": "Gateway name already exists"}, status_code=400)
18111813
if isinstance(ex, RuntimeError):
18121814
return JSONResponse(content={"message": "Error during execution"}, status_code=500)
18131815
return JSONResponse(content={"message": "Unexpected error"}, status_code=500)

mcpgateway/services/gateway_service.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ async def register_gateway(self, db: Session, gateway: GatewayCreate) -> Gateway
392392
ge: ExceptionGroup[GatewayConnectionError]
393393
logger.error(f"GatewayConnectionError in group: {ge.exceptions}")
394394
raise ge.exceptions[0]
395+
except* GatewayNameConflictError as gnce:
396+
if TYPE_CHECKING:
397+
gnce: ExceptionGroup[GatewayNameConflictError]
398+
logger.error(f"GatewayNameConflictError in group: {gnce.exceptions}")
399+
raise gnce.exceptions[0]
395400
except* ValueError as ve:
396401
if TYPE_CHECKING:
397402
ve: ExceptionGroup[ValueError]

0 commit comments

Comments
 (0)