Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions mcpgateway/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12339,15 +12339,16 @@ async def admin_edit_gateway(
auth_headers = []

# Handle passthrough_headers
passthrough_headers = str(form.get("passthrough_headers"))
if passthrough_headers and passthrough_headers.strip():
# Use [] (empty list) to signal "user cleared the field" vs None (not provided)
passthrough_headers_raw = form.get("passthrough_headers")
passthrough_headers_str = str(passthrough_headers_raw) if passthrough_headers_raw else ""
passthrough_headers: Optional[List[str]] = []
if passthrough_headers_str.strip():
try:
passthrough_headers = orjson.loads(passthrough_headers)
passthrough_headers = orjson.loads(passthrough_headers_str)
except (orjson.JSONDecodeError, ValueError):
# Fallback to comma-separated parsing
passthrough_headers = [h.strip() for h in passthrough_headers.split(",") if h.strip()]
else:
passthrough_headers = None
passthrough_headers = [h.strip() for h in passthrough_headers_str.split(",") if h.strip()]

# Parse OAuth configuration - support both JSON string and individual form fields
oauth_config_json = str(form.get("oauth_config"))
Expand Down
5 changes: 3 additions & 2 deletions mcpgateway/services/gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2144,11 +2144,12 @@ async def update_gateway(
prompt.visibility = gateway.visibility
if gateway_update.passthrough_headers is not None:
if isinstance(gateway_update.passthrough_headers, list):
gateway.passthrough_headers = gateway_update.passthrough_headers
# [] means "user cleared the field" β†’ store None in DB
gateway.passthrough_headers = gateway_update.passthrough_headers if gateway_update.passthrough_headers else None
else:
if isinstance(gateway_update.passthrough_headers, str):
parsed: List[str] = [h.strip() for h in gateway_update.passthrough_headers.split(",") if h.strip()]
gateway.passthrough_headers = parsed
gateway.passthrough_headers = parsed if parsed else None
else:
raise GatewayError("Invalid passthrough_headers format: must be list[str] or comma-separated string")

Expand Down