fix: #1370 Custom Headers now are visible when editing saved servers #1371
+350
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_valueand legacy single-header fields.Because the encoded value was never decoded for the UI,
auth-headers-container-gw-editstayed empty, so the Custom Headers section appeared blank.💡 Fix Description
GatewayReadto 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)).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)).GatewayService.update_gateway (mcpgateway/services/gateway_service.py (line 1194)).(tests/unit/mcpgateway/test_multi_auth_headers.py (line 20), tests/unit/mcpgateway/test_multi_auth_headers.py (line 262)).🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)Evidences