Skip to content

Conversation

@aakashH242
Copy link
Contributor

Signed-off-by: Aakash [email protected]

🐛 Bug-fix PR


📌 Summary

Editing a gateway saved with “Custom Headers” auth now shows the previously saved headers again. At the same time we keep other auth fields stable and mask actual secrets to avoid accidental leakage.

🔁 Reproduction Steps

#1370

🐞 Root Cause

The admin template re-renders the modal from the REST response, but the response only included the encoded auth_value and legacy single-header fields.
Because the encoded value was never decoded for the UI, auth-headers-container-gw-edit stayed empty, so the Custom Headers section appeared blank.

💡 Fix Description

  • Extended GatewayRead to emit the decoded header list (plus unmasked copies for the UI) while still masking the user-facing strings (mcpgateway/schemas.py (line 3148), mcpgateway/schemas.py (line 3188)).
  • Reworked the edit modal to call loadAuthHeaders("auth-headers-container-gw-edit", gateway.authHeadersUnmasked, { maskValues: true }), which rehydrates each header row and remembers the real value behind the mask (mcpgateway/static/admin.js (line 4335), mcpgateway/static/admin.js (line 11580), mcpgateway/static/admin.js (line 11822)).
  • When saving, the server now preserves unchanged secrets by merging masked placeholders back with the stored values in GatewayService.update_gateway (mcpgateway/services/gateway_service.py (line 1194)).
  • Added regression coverage to prove the schema surfaces the unmasked headers and that updates keep masked rows intact (tests/unit/mcpgateway/test_multi_auth_headers.py (line 20), tests/unit/mcpgateway/test_multi_auth_headers.py (line 262)).

🧪 Verification

Check Command Status
Lint suite make lint Pass
Unit tests make test Pass
Coverage ≥ 90 % make coverage Pass
Manual regression no longer fails steps / screenshots Attached

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

Evidences

  • Create a connection with Custom Headers.
save_with_custom_headers
  • Edit the created connection - the headers are now visible.
edit_with_custom_headers

@aakashH242 aakashH242 force-pushed the bug/#1370-custom-headers-not-shown-in-edit branch from cd37035 to 1d103d6 Compare October 30, 2025 11:57
@aakashH242
Copy link
Contributor Author

Hi @crivetimihai requesting your review on this PR. Happy to address any feedback you have.

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.

1 participant