Skip to content

fix(admin): allow clearing passthrough_headers via gateway edit form#4229

Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:fix/passthrough-headers-clearing
Open

fix(admin): allow clearing passthrough_headers via gateway edit form#4229
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:fix/passthrough-headers-clearing

Conversation

@ecthelion77
Copy link
Copy Markdown
Contributor

🐛 Bug-fix PR

Fixes #4228

📌 Summary

Passthrough headers cannot be cleared once set on a gateway via the admin edit form. Clearing the field and saving silently preserves the old values.

🔁 Reproduction Steps

  1. Create a gateway with passthrough_headers set (e.g. ["Authorization"])
  2. Edit the gateway, clear the passthrough_headers field
  3. Save — the field still shows the previous values

🐞 Root Cause

Two bugs:

  1. admin.py: str(form.get("passthrough_headers")) converts empty/None to the string "None", which is truthy. The parsing logic treats it as valid content instead of a cleared field, so passthrough_headers is never set to signal clearing.

  2. gateway_service.py: Even if an empty list [] is passed (meaning "user cleared the field"), it is stored as-is in the database. The canonical representation for "no passthrough headers" is None, not [].

💡 Fix Description

  • admin.py: Distinguish between "field cleared" (empty string → set passthrough_headers = [] to signal clearing) and "field not provided" (None → no change). Avoid str() coercion on raw form value.

  • gateway_service.py: Convert empty list [] to None before storing, so the DB always uses None to mean "no passthrough headers".

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Manual regression no longer fails Clear field, save, verify cleared

📐 MCP Compliance

  • No change to MCP protocol behavior
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted
  • No secrets/credentials committed
  • DCO Signed-off-by included

Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.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.

Bug: passthrough_headers cannot be cleared via gateway edit form

1 participant