Skip to content

Conversation

rakdutta
Copy link
Collaborator

@rakdutta rakdutta commented Aug 1, 2025

#363

This PR includes the following changes and enhancements related to gateway editing:

Refactored admin.py:

  • Updated the admin_edit_gateway function to handle ValidationError and IntegrityError exceptions gracefully.

Updated gateway_service.py:

  • Modified logic in mcpgateway/services/gateway_service.py to support improved validation and error handling during edit gateway.

Enhanced admin.js:

  • Implemented changes to redirect users to the appropriate page after gateway edit operations.

Test Improvements:

  • Updated test_admin.py to validate the new error responses for the Edit Gateway functionality.

Issue Fix – #603:

  • Addressed the issue by updating the register_gateway function in main.py.

Testing Steps:

  1. Registering gateway server with name mcp-server1:
    curl -v -X POST http://127.0.0.1:4444/gateways
    -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN"
    -H "Content-Type: application/json"
    -d '{"name":"mcp-server","url":"http://localhost:8080/sse","transport":"SSE"}' | jq

✅ Result: Successfully registered.

  1. Attempt to register another gateway with the same URL but a different name:
    curl -v -X POST http://127.0.0.1:4444/gateways
    -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN"
    -H "Content-Type: application/json"
    -d '{"name":"mcp-server1","url":"http://localhost:8080/sse","transport":"SSE"}' | jq

❌ Response:
{
"message": "A gateway with this URL already exists",
"success": false
}

  1. Attempt to register another gateway with the same name but a different URL:
    curl -v -X POST http://127.0.0.1:4444/gateways
    -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN"
    -H "Content-Type: application/json"
    -d '{"name":"mcp-server","url":"http://localhost:8000/sse","transport":"SSE"}' | jq
    ❌ Response:
    {
    "message": "Gateway name already exists"
    }

rakdutta1 and others added 9 commits July 30, 2025 12:52
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
Signed-off-by: RAKHI DUTTA <[email protected]>
@MohanLaksh
Copy link
Collaborator

@crivetimihai , @madhav165 , @rakdutta

Feature Testing Complete - works as intended/described

PR Test summary

  1. make serve - pass
  2. make test - pass (80%, === 1127 passed, 10 skipped, 50 warnings in 61.33s (0:01:01) ===)
  3. make autoflake isort black flake8 - pass
  4. make pylint - pass (Your code has been rated at 10.00/10 )
  5. make smoketest - ✅ Smoketest passed!
  6. make doctest - pass (58%, 372 passed, 8 skipped in 17.21s)

GOOD to MERGE

Copy link
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of PR #648 ("Improved Error for edit gateway for Issue #361 and Bug fixing of issue #603"):

  • Refactors the admin_edit_gateway flow to return detailed JSON error responses (rather than only redirects), handling ValidationError and IntegrityError gracefully.
  • Improves error handling in gateway_service.py and main.py for gateway edit and registration, including better reporting for name and URL conflicts, validation errors, and DB integrity issues.
  • Updates the frontend (admin.js) to handle new response formats, show error messages, and redirect only on success.
  • Adjusts unit tests to check for the new error handling and response structure.
  • Addresses issues #361 (edit gateway error handling) and #603 (bug in registration with duplicate names/URLs).

Major changes:

  • All gateway edit API errors (validation, DB integrity, etc.) now return specific JSON responses with status codes (400, 409, 422, 500, etc.).
  • Frontend now properly displays error messages and only redirects on successful edit.
  • Test coverage updated for new behaviors.

Passed make lint-web doctest test

@crivetimihai crivetimihai merged commit 6b4ff13 into IBM:main Aug 1, 2025
36 checks passed
@rakdutta rakdutta changed the title Improved Error for edit gateway for Issue #361 and Bug fixing of issue #603 Improved Error for edit gateway for Issue #363 and Bug fixing of issue #603 Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants