Skip to content

fix: remove HX-Retarget headers in team creation error handlers#2841

Merged
crivetimihai merged 1 commit intomainfrom
2800-remove-HX-Retarget-headers-in-team-creation-error-handlers
Feb 11, 2026
Merged

fix: remove HX-Retarget headers in team creation error handlers#2841
crivetimihai merged 1 commit intomainfrom
2800-remove-HX-Retarget-headers-in-team-creation-error-handlers

Conversation

@marekdano
Copy link
Copy Markdown
Collaborator

🐛 Bug-fix PR


📌 Summary

The team creation form's has hx-target=#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.

Closes #2800

🔁 Reproduction Steps

  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

💡 Fix Description

Removed 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

Changes Made:

  1. mcpgateway/admin.py - Removed redundant headers from 5 error handlers:
    - Line 4028-4029: Email auth disabled error (403)
    - Line 4044-4045: Missing team name error (400)
    - Line 4080-4081: Validation error (400) + removed obsolete comment
    - Line 4090-4091: IntegrityError (400)
    - Line 4099-4100: Generic Exception (400)

  2. tests/unit/mcpgateway/test_admin.py - Removed 5 redundant test assertions:
    - test_admin_create_team_disabled
    - test_admin_create_team_missing_name
    - test_admin_create_team_validation_error_message_cleaned
    - test_admin_create_team_integrity_error_non_unique
    - test_admin_create_team_unexpected_exception

🧪 Verification

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

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

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

Signed-off-by: Marek Dano <mk.dano@gmail.com>
@crivetimihai crivetimihai force-pushed the 2800-remove-HX-Retarget-headers-in-team-creation-error-handlers branch from 8c57504 to 1cd9b5b Compare February 11, 2026 17:22
Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean, correct, well-scoped fix.

Correctness verified:

  • The create-team form (admin.html:14197-14203) already sets hx-target="#create-team-error" and hx-swap="innerHTML", so the server-side HX-Retarget/HX-Reswap headers were overriding to the same target — genuinely redundant.

Consistency check:

  • The edit-team and edit-user forms do not have hx-target pointing to their error containers in the HTML template, so their HX-Retarget headers are genuinely needed. This PR correctly leaves those untouched.

No security or performance concerns. Error messages already use html.escape(). All 7 test_admin_create_team* tests pass.

Rebased onto current main (054d2b3), no conflicts.

@crivetimihai crivetimihai merged commit 6d46595 into main Feb 11, 2026
47 checks passed
@crivetimihai crivetimihai deleted the 2800-remove-HX-Retarget-headers-in-team-creation-error-handlers branch February 11, 2026 17:59
ja8zyjits pushed a commit that referenced this pull request Feb 13, 2026
vishu-bh pushed a commit that referenced this pull request Feb 18, 2026
Signed-off-by: Marek Dano <mk.dano@gmail.com>
Signed-off-by: Vishu Bhatnagar <vishu.bhatnagar@ibm.com>
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
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][UI]: Redundant HX-Retarget headers in team creation error handlers after #2780

2 participants