Skip to content

fix(group): preserve explicit 404 routes across Use calls - #3154

Closed
tianrking wants to merge 1 commit into
labstack:masterfrom
tianrking:codex/echo-group-notfound
Closed

tianrking wants to merge 1 commit into
labstack:masterfrom
tianrking:codex/echo-group-notfound

Conversation

@tianrking

Copy link
Copy Markdown

Description

Calling Group.Use after registering a custom catch-all RouteNotFound currently replaces that handler with the default 404. Preserve the successfully registered group route and its route-level middleware when rebuilding the catch-all with the latest group middleware. This also retains the route name, copies the middleware slice, and discards saved routes that have been removed.

The regressions cover both catch-all paths, registration order, repeated Use, rejected registrations, middleware order and ownership, disabled automatic registration, route removal, and an actual HTTP request with connection cleanup.

Closes #3153.

Validation

  • Native original-production replay: 8 failing scenarios and 5 passing controls; the corrected code passes all 13 scenarios.
  • Exact source commit f6051c1c9c844d35c88776fa45a3e657480f7c24: full race and coverage tests on Go 1.25.14 and 1.27.1, covering all three packages, with no failed or skipped tests.
  • make check, explicit golint -set_exit_status ./..., staticcheck ./..., go vet ./..., go test -short -count=1 ./..., govulncheck ./..., and changed-file gofmt checks pass.
  • Complete original/fixed benchmarks ran with eight samples at 100ms each; the comparison is advisory, as in the project's CI.

Hosted native validation and source hashes, benchmark comparison using the unchanged recorded measurements.

@vishr

vishr commented Oct 5, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. Closing along with #3153. The order dependence is by design (#2411), so we're documenting it rather than adding per-group tracking state.

@vishr vishr closed this Oct 5, 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.

Group.Use() silently replaces an explicitly registered group RouteNotFound handler

2 participants