Skip to content

Conversation

@rakdutta
Copy link
Collaborator

Summary of Changes:

  • Updated mcpgateway/frontend/admin.js to add null/undefined checks in all form handlers, in line with issue #668.
  • Introduced optional chaining and default error messages to handle cases where result.message might be missing.
  • Ensured all error messages fall back to a sensible default if the backend response does not include a message.
  • Improved robustness and user experience by preventing runtime errors due to unexpected null or undefined values.

Testing Instructions

These steps validate changes for handleGatewayFormSubmit and handleEditGatewayFormSubmit.
Repeat similar tests for other form handlers.

  • Locate the line in admin.js:

    const result = await response.json();
  • Case 1: Replace with:

    const result = null;

    Expected Result:

    • "Failed to add gateway"
    • "Failed to edit gateway"
  • Case 2: Replace with:

    const result = { success: false };

    Expected Result:

    • "Failed to add gateway"
    • "Failed to edit gateway"

@rakdutta rakdutta added this to the Release 0.6.0 milestone Aug 12, 2025
@rakdutta rakdutta marked this pull request as ready for review August 13, 2025 05:06
@rakdutta rakdutta requested a review from crivetimihai as a code owner August 13, 2025 05:06
Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
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.

✅ Successfully rebased PR #726 onto latest main

Changes Review: The PR improves error handling in mcpgateway/static/admin.js by:

  • Adding null/undefined checks using optional chaining (result?.message)
  • Providing specific fallback error messages for each form handler
  • Ensuring consistent error handling across all 9 form submission functions

Code Quality:

  • ✅ Clean implementation following modern JS best practices
  • ✅ All web linters pass (HTML, CSS, JS security checks)
  • ✅ All Python tests pass (1643 passed, 11 skipped)
  • ✅ Successfully rebased with minimal conflicts (only whitespace issues)

The PR correctly addresses issue #668 and improves the robustness of the admin UI error handling.

@crivetimihai crivetimihai merged commit 7f95925 into IBM:main Aug 13, 2025
36 checks passed
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
…BM#726)

* issue 668

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* prettier

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

---------

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Co-authored-by: RAKHI DUTTA <rakdutta@in.ibm.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
…BM#726)

* issue 668

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* prettier

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

---------

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Co-authored-by: RAKHI DUTTA <rakdutta@in.ibm.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 16, 2025
…BM#726)

* issue 668

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* prettier

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

* admin.js

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>

---------

Signed-off-by: RAKHI DUTTA <rakdutta@in.ibm.com>
Co-authored-by: RAKHI DUTTA <rakdutta@in.ibm.com>
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.

3 participants