Skip to content

fix: resolve ServeMux conflict between attachments and SMTP message routes#336

Merged
butschster merged 1 commit into
masterfrom
fix/smtp-route-conflict
May 13, 2026
Merged

fix: resolve ServeMux conflict between attachments and SMTP message routes#336
butschster merged 1 commit into
masterfrom
fix/smtp-route-conflict

Conversation

@butschster
Copy link
Copy Markdown
Member

What

Server panics at boot with pattern "GET /api/smtp/{eventUuid}/attachments/{uuid}" ... conflicts with pattern "GET /api/smtp/message/{uuid}/raw". This PR nests the attachment routes under a literal /attachments/ segment so they no longer collide with the SMTP module's 4-segment routes.

Why

The attachment API was registered as /api/{module}/{eventUuid}/attachments/{uuid} — wildcard at position 2. After #334 added /api/smtp/message/{uuid}/raw, both 4-segment patterns claim /api/smtp/message/attachments/raw and Go 1.22's ServeMux refuses to register them.

panic: pattern "GET /api/smtp/{eventUuid}/attachments/{uuid}" ...
       conflicts with pattern "GET /api/smtp/message/{uuid}/raw":
       But neither is more specific than the other.

How

  • internal/server/http/attachments.go — routes are now /api/{module}/attachments/{eventUuid}[/{uuid}][/preview/{uuid}]. The attachments literal at position 2 makes them disjoint from any future module-specific route at position 2.
  • modules/httpdumps/handler.go:109 — the generated attachment URI follows the new layout.
  • Companion frontend PR: buggregator/frontend#282 updates src/shared/lib/io/use-attachments.ts to call the new paths. Both PRs must land together.

Testing

  • internal/server/http/attachments_test.go (new) — registers RegisterAttachmentAPI and the SMTP module on the same mux and asserts no panic. Without the fix this panics at registration.
  • go test ./... -count=1 clean; go vet ./... clean.

Note

PR #335 is independent and can be rebased on top of this once it lands.

…outes

RegisterAttachmentAPI used /api/{module}/{eventUuid}/attachments/{uuid},
which Go 1.22's ServeMux rejects against the newly added SMTP routes at
/api/smtp/message/{uuid}/raw — both are 4-segment patterns and neither
is more specific, so the server panics at boot. Nest the attachment
routes under a literal /attachments segment instead so collisions can't
recur as more module-specific 4-segment paths are added.
@butschster butschster added type: bug Something is broken or behaves incorrectly priority: critical Production-impacting, data loss, security regression Worked before, broke later labels May 13, 2026
@butschster butschster merged commit f1b55d9 into master May 13, 2026
1 check passed
@butschster butschster deleted the fix/smtp-route-conflict branch May 13, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: critical Production-impacting, data loss, security regression Worked before, broke later type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant