Skip to content

[BUG][UI]: Redundant HX-Retarget headers in team creation error handlers after #2780 #2800

@crivetimihai

Description

@crivetimihai

🐞 Bug Summary

After #2780 changed the team creation form's hx-target from #unified-teams-list to #create-team-error, all error handlers in admin_create_team() still send HX-Retarget: #create-team-error and HX-Reswap: innerHTML headers. These headers are now redundant — they retarget to the element that is already the form's default target.

This is not a functional bug (behavior is correct), but it is dead code that obscures the actual HTMX flow and could confuse future maintainers.


🧩 Affected Component

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

🔁 Steps to Reproduce

  1. Read mcpgateway/admin.py lines 4025-4101
  2. Observe that the form's hx-target is #create-team-error (set in admin.html:14157)
  3. Observe all error handlers set HX-Retarget: #create-team-error — same target

🤔 Expected Behavior

Either:

  • Remove the redundant HX-Retarget and HX-Reswap headers from all error handlers (lines 4028-4029, 4044-4045, 4080-4081, 4090-4091, 4099-4100), since the form already targets #create-team-error
  • Or document that they are intentionally kept as defensive headers

Note: The htmx:beforeSwap handler at admin.html:40-57 checks hasRetarget to decide whether to swap 4xx responses. However, it also checks isTeamForm (via data-team-validation="true" attribute), which is independently sufficient. So removing HX-Retarget will not break the swap behavior for this form.


📓 Logs / Error Output

N/A — no functional impact.


🧩 Additional Context

Discovered during review of PR #2780. Before that PR, hx-target was #unified-teams-list, so HX-Retarget: #create-team-error was essential to redirect errors away from the teams list. After #2780, the target changed but the headers were not cleaned up.

Low priority — cosmetic code hygiene.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingchoreLinting, formatting, dependency hygiene, or project maintenance choresfrontendFrontend development (HTML, CSS, JavaScript)

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions