Skip to content

test: add HandleContext abort regression tests for internal redirect (#2944) - #4790

Open
stareezy-1 wants to merge 1 commit into
gin-gonic:masterfrom
stareezy-1:fix/2944-handlecontext-abort
Open

test: add HandleContext abort regression tests for internal redirect (#2944)#4790
stareezy-1 wants to merge 1 commit into
gin-gonic:masterfrom
stareezy-1:fix/2944-handlecontext-abort

Conversation

@stareezy-1

Copy link
Copy Markdown

What

Adds two regression tests for the internal-redirect abort scenario reported in #2944:

  • TestEngineHandleContextAbortPreventsTargetHandler
  • TestEngineHandleContextAbortWithNextPreventsTargetHandler

Why

#2944 reports that when a route internally redirects via HandleContext and the target chain's middleware calls Abort, the target handler still runs ({"result":"mid"}{"result":"t2"}).

The behavior was fixed by #3987 (which restores c.handlers after re-entry), but no regression test covers the abort path — the existing TestEngineHandleContextPreventsMiddlewareReEntry only counts handler invocations without aborting.

Verification

Both tests fail against 8763f33~1 (pre-#3987 code) with the reported double output, and pass on master. Full suite passes: go test ./....

…in-gonic#2944)

When a route internally redirects via HandleContext and the target
chain's middleware aborts, the target handler must not run after
HandleContext returns. These tests pin the behavior fixed by gin-gonic#3987;
both fail without the handlers-restore fix.
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.

1 participant