Cannot merge pull request #15007

Closed
opened 2025-11-02 11:27:53 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @badhezi on GitHub (Oct 8, 2025).

Originally assigned to: @lunny on GitHub.

Description

Needs feedback
Can't seem to merge a pull request

When creating a simple pull request from the UI and then trying to "create merge commit"
gitea server errors out with below log

Possibly introduced by this commit 69f5ee970c

03fce8f3d0/modules/git/gitcmd/command.go (L473)

panics because c.opts.Stdout and c.opts.Stderr and not nil
03fce8f3d0/modules/git/gitcmd/command.go (L471)

Debugger shows c.opts.Stdout and c.opts.Stderr are not nil and are initialized to
io.Writer(*strings.Builder) *{addr: *strings.Builder nil, buf: []uint8 len: 0, cap: 0, nil}

Image

Gitea Version

main 03fce8f3d0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

Image

logs:

2025/10/08 15:42:56 HTTPRequest [W] router: failed    POST /gitea_admin/merge-me/pulls/1/merge for [::1]:57214, panic in 212.7ms @ repo/pull.go:1014(repo.MergePullRequest), err=stdout and stderr field must be nil when using RunStdBytes
2025/10/08 15:42:56 routers/common/errpage.go:25:RenderPanicErrorPage() [E] PANIC: stdout and stderr field must be nil when using RunStdBytes
/usr/local/go/src/runtime/panic.go:783 (0x10090eaff)
        gopanic: fn()
/Users/heziaharon/Documents/repos/gitea/modules/web/routing/logger_manager.go:116 (0x1019792cb)
        (*requestRecordsManager).handler-fm.(*requestRecordsManager).handler.func1.1: panic(localPanicErr)
/usr/local/go/src/runtime/panic.go:783 (0x10090eaff)
        gopanic: fn()
/Users/heziaharon/Documents/repos/gitea/modules/git/gitcmd/command.go:473 (0x101139cf3)
        (*Command).runStdBytes: panic("stdout and stderr field must be nil when using RunStdBytes")
/Users/heziaharon/Documents/repos/gitea/modules/git/gitcmd/command.go:461 (0x1011399cb)
        (*Command).RunStdString: stdoutBytes, stderrBytes, runErr := c.WithParentCallerInfo().runStdBytes(ctx)
/Users/heziaharon/Documents/repos/gitea/services/pull/merge_prepare.go:76 (0x102048387)
        createTemporaryRepoForMerge: trackingCommitID, _, err := mergeCtx.PrepareGitCmd(gitcmd.NewCommand("show-ref", "--hash").AddDynamicArguments(git.BranchPrefix + trackingBranch)).RunStdString(ctx)
/Users/heziaharon/Documents/repos/gitea/services/pull/merge.go:331 (0x102044047)
        doMergeAndPush: mergeCtx, cancel, err := createTemporaryRepoForMerge(ctx, pr, doer, expectedHeadCommitID)
/Users/heziaharon/Documents/repos/gitea/services/pull/merge.go:262 (0x102043853)
        Merge: _, err = doMergeAndPush(ctx, pr, doer, mergeStyle, expectedHeadCommitID, message, repo_module.PushTriggerPRMergeToBase)
/Users/heziaharon/Documents/repos/gitea/routers/web/repo/pull.go:1115 (0x1029938c3)
        MergePullRequest: if err := pull_service.Merge(ctx, pr, ctx.Doer, ctx.Repo.GitRepo, repo_model.MergeStyle(form.Do), form.HeadCommitID, message, false); err != nil {
/usr/local/go/src/reflect/value.go:581 (0x10099508f)
        Value.call: call(frametype, fn, stackArgs, uint32(frametype.Size()), uint32(abid.retOffset), uint32(frameSize), &regArgs)
/usr/local/go/src/reflect/value.go:365 (0x100994563)
        Value.Call: return v.call("Call", in)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:161 (0x101981467)
        toHandlerProvider.func1.1: ret := fn.Call(argsIn)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/chain.go:31 (0x101979b8b)
        (*ChainHandler).ServeHTTP: c.chain.ServeHTTP(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b)
        (*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/middleware/get_head.go:37 (0x1029176a7)
        GetHead.func1: next.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb)
        toHandlerProvider.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/services/context/context.go:210 (0x101ed05b3)
        Contexter.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20250926004215-636cadd82e15/session.go:257 (0x10192bc0b)
        Sessioner.func1.1: next.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:73 (0x10197a663)
        (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:321 (0x10197bc53)
        (*Mux).Mount.func1: handler.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b)
        (*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:73 (0x10197a663)
        (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:321 (0x10197bc53)
        (*Mux).Mount.func1: handler.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b)
        (*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/routing/logger_manager.go:122 (0x101979187)
        (*requestRecordsManager).handler-fm.(*requestRecordsManager).handler.func1: next.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x10287523b)
        ForwardedHeadersHandler.ForwardedHeaders.func1.1: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/routers/common/middleware.go:78 (0x1028774df)
        ProtocolMiddlewares.RequestContextHandler.func2.1: next.ServeHTTP(respWriter, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/routers/common/middleware.go:93 (0x10287713b)
        ProtocolMiddlewares.ChiRoutePathHandler.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883)
        toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2322 (0x100d72017)
        HandlerFunc.ServeHTTP: f(w, r)
/Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:90 (0x10197a623)
        (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/Users/heziaharon/Documents/repos/gitea/modules/web/router.go:243 (0x10198306b)
        (*Router).normalizeRequestPath: next.ServeHTTP(resp, req)
/Users/heziaharon/Documents/repos/gitea/modules/web/router.go:181 (0x101982b6f)
        (*Router).ServeHTTP: r.normalizeRequestPath(w, req, r.chiRouter)
/usr/local/go/src/net/http/server.go:3340 (0x100d8f1ff)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:2109 (0x100d70407)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_arm64.s:1268 (0x100917503)
        goexit: MOVD    R0, R0  // NOP

Git Version

2.39.5

Operating System

macos

How are you running Gitea?

Local setup make watch

Database

PostgreSQL

Originally created by @badhezi on GitHub (Oct 8, 2025). Originally assigned to: @lunny on GitHub. ### Description Needs feedback Can't seem to merge a pull request When creating a simple pull request from the UI and then trying to "create merge commit" gitea server errors out with below log Possibly introduced by this commit https://github.com/go-gitea/gitea/commit/69f5ee970c2f288d0749cab4289b46765d9e3470 https://github.com/go-gitea/gitea/blob/03fce8f3d0cf3c180f06470257dc09a6c09ec5b0/modules/git/gitcmd/command.go#L473 panics because `c.opts.Stdout` and `c.opts.Stderr` and not nil https://github.com/go-gitea/gitea/blob/03fce8f3d0cf3c180f06470257dc09a6c09ec5b0/modules/git/gitcmd/command.go#L471 Debugger shows `c.opts.Stdout` and `c.opts.Stderr` are not nil and are initialized to io.Writer(*strings.Builder) *{addr: *strings.Builder nil, buf: []uint8 len: 0, cap: 0, nil} <img width="863" height="268" alt="Image" src="https://github.com/user-attachments/assets/551c6c2f-c26d-438a-be06-f7f0efa1bb09" /> ### Gitea Version main 03fce8f3d0cf3c180f06470257dc09a6c09ec5b0 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots <img width="1959" height="857" alt="Image" src="https://github.com/user-attachments/assets/e261c1f9-5fee-40e6-9e5c-70bfb30ccd65" /> logs: ``` 2025/10/08 15:42:56 HTTPRequest [W] router: failed POST /gitea_admin/merge-me/pulls/1/merge for [::1]:57214, panic in 212.7ms @ repo/pull.go:1014(repo.MergePullRequest), err=stdout and stderr field must be nil when using RunStdBytes 2025/10/08 15:42:56 routers/common/errpage.go:25:RenderPanicErrorPage() [E] PANIC: stdout and stderr field must be nil when using RunStdBytes /usr/local/go/src/runtime/panic.go:783 (0x10090eaff) gopanic: fn() /Users/heziaharon/Documents/repos/gitea/modules/web/routing/logger_manager.go:116 (0x1019792cb) (*requestRecordsManager).handler-fm.(*requestRecordsManager).handler.func1.1: panic(localPanicErr) /usr/local/go/src/runtime/panic.go:783 (0x10090eaff) gopanic: fn() /Users/heziaharon/Documents/repos/gitea/modules/git/gitcmd/command.go:473 (0x101139cf3) (*Command).runStdBytes: panic("stdout and stderr field must be nil when using RunStdBytes") /Users/heziaharon/Documents/repos/gitea/modules/git/gitcmd/command.go:461 (0x1011399cb) (*Command).RunStdString: stdoutBytes, stderrBytes, runErr := c.WithParentCallerInfo().runStdBytes(ctx) /Users/heziaharon/Documents/repos/gitea/services/pull/merge_prepare.go:76 (0x102048387) createTemporaryRepoForMerge: trackingCommitID, _, err := mergeCtx.PrepareGitCmd(gitcmd.NewCommand("show-ref", "--hash").AddDynamicArguments(git.BranchPrefix + trackingBranch)).RunStdString(ctx) /Users/heziaharon/Documents/repos/gitea/services/pull/merge.go:331 (0x102044047) doMergeAndPush: mergeCtx, cancel, err := createTemporaryRepoForMerge(ctx, pr, doer, expectedHeadCommitID) /Users/heziaharon/Documents/repos/gitea/services/pull/merge.go:262 (0x102043853) Merge: _, err = doMergeAndPush(ctx, pr, doer, mergeStyle, expectedHeadCommitID, message, repo_module.PushTriggerPRMergeToBase) /Users/heziaharon/Documents/repos/gitea/routers/web/repo/pull.go:1115 (0x1029938c3) MergePullRequest: if err := pull_service.Merge(ctx, pr, ctx.Doer, ctx.Repo.GitRepo, repo_model.MergeStyle(form.Do), form.HeadCommitID, message, false); err != nil { /usr/local/go/src/reflect/value.go:581 (0x10099508f) Value.call: call(frametype, fn, stackArgs, uint32(frametype.Size()), uint32(abid.retOffset), uint32(frameSize), &regArgs) /usr/local/go/src/reflect/value.go:365 (0x100994563) Value.Call: return v.call("Call", in) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:161 (0x101981467) toHandlerProvider.func1.1: ret := fn.Call(argsIn) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/chain.go:31 (0x101979b8b) (*ChainHandler).ServeHTTP: c.chain.ServeHTTP(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b) (*Mux).routeHTTP: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/middleware/get_head.go:37 (0x1029176a7) GetHead.func1: next.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:168 (0x1019814bb) toHandlerProvider.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/services/context/context.go:210 (0x101ed05b3) Contexter.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20250926004215-636cadd82e15/session.go:257 (0x10192bc0b) Sessioner.func1.1: next.ServeHTTP(w, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:73 (0x10197a663) (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:321 (0x10197bc53) (*Mux).Mount.func1: handler.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b) (*Mux).routeHTTP: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:73 (0x10197a663) (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:321 (0x10197bc53) (*Mux).Mount.func1: handler.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:477 (0x10197c66b) (*Mux).routeHTTP: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/routing/logger_manager.go:122 (0x101979187) (*requestRecordsManager).handler-fm.(*requestRecordsManager).handler.func1: next.ServeHTTP(w, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x10287523b) ForwardedHeadersHandler.ForwardedHeaders.func1.1: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/routers/common/middleware.go:78 (0x1028774df) ProtocolMiddlewares.RequestContextHandler.func2.1: next.ServeHTTP(respWriter, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/routers/common/middleware.go:93 (0x10287713b) ProtocolMiddlewares.ChiRoutePathHandler.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/handler.go:125 (0x101981883) toHandlerProvider.wrapHandlerProvider[...].func2.1: h.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2322 (0x100d72017) HandlerFunc.ServeHTTP: f(w, r) /Users/heziaharon/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.3/mux.go:90 (0x10197a623) (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r) /Users/heziaharon/Documents/repos/gitea/modules/web/router.go:243 (0x10198306b) (*Router).normalizeRequestPath: next.ServeHTTP(resp, req) /Users/heziaharon/Documents/repos/gitea/modules/web/router.go:181 (0x101982b6f) (*Router).ServeHTTP: r.normalizeRequestPath(w, req, r.chiRouter) /usr/local/go/src/net/http/server.go:3340 (0x100d8f1ff) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /usr/local/go/src/net/http/server.go:2109 (0x100d70407) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /usr/local/go/src/runtime/asm_arm64.s:1268 (0x100917503) goexit: MOVD R0, R0 // NOP ``` ### Git Version 2.39.5 ### Operating System macos ### How are you running Gitea? Local setup `make watch` ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 11:27:53 -06:00
Author
Owner

@badhezi commented on GitHub (Oct 8, 2025):

FYI setting stdout and stderr to nil instead of an empty builder resolves the issue
Before:

func (ctx *mergeContext) PrepareGitCmd(cmd *gitcmd.Command) *gitcmd.Command {
	ctx.outbuf.Reset()
	ctx.errbuf.Reset()
	return cmd.WithEnv(ctx.env).
		WithDir(ctx.tmpBasePath).
		WithParentCallerInfo().
		WithStdout(ctx.outbuf).
		WithStderr(ctx.errbuf)
}

After:

func (ctx *mergeContext) PrepareGitCmd(cmd *gitcmd.Command) *gitcmd.Command {
	ctx.outbuf.Reset()
	ctx.errbuf.Reset()
	return cmd.WithEnv(ctx.env).
		WithDir(ctx.tmpBasePath).
		WithParentCallerInfo().
		WithStdout(nil).
		WithStderr(nil)
}

I'm just not sure what are the other implications of this perhaps @lunny can help, other commands run fine as PrepareGitCmd is only called in merge flows, it seems.

it stems from using WithStdout() or WithStderr() set to an empty io.Writer and then the command is called from RunStdString() or RunStdBytes()

Edit:
The test case at
03fce8f3d0/tests/integration/pull_merge_test.go (L46)

does not fail because it is required to supply the request form with head_commit_id which will take us to

	if expectedHeadCommitID != "" {
		trackingCommitID, _, err := mergeCtx.PrepareGitCmd(gitcmd.NewCommand("show-ref", "--hash").AddDynamicArguments(git.BranchPrefix + trackingBranch)).RunStdString(ctx)

it's included when calling merge from the UI but not from this test case.

@badhezi commented on GitHub (Oct 8, 2025): FYI setting stdout and stderr to nil instead of an empty builder resolves the issue Before: ``` func (ctx *mergeContext) PrepareGitCmd(cmd *gitcmd.Command) *gitcmd.Command { ctx.outbuf.Reset() ctx.errbuf.Reset() return cmd.WithEnv(ctx.env). WithDir(ctx.tmpBasePath). WithParentCallerInfo(). WithStdout(ctx.outbuf). WithStderr(ctx.errbuf) } ``` After: ``` func (ctx *mergeContext) PrepareGitCmd(cmd *gitcmd.Command) *gitcmd.Command { ctx.outbuf.Reset() ctx.errbuf.Reset() return cmd.WithEnv(ctx.env). WithDir(ctx.tmpBasePath). WithParentCallerInfo(). WithStdout(nil). WithStderr(nil) } ``` I'm just not sure what are the other implications of this perhaps @lunny can help, other commands run fine as `PrepareGitCmd` is only called in merge flows, it seems. it stems from using `WithStdout()` or` WithStderr()` set to an empty io.Writer and then the command is called from `RunStdString()` or `RunStdBytes()` Edit: The test case at https://github.com/go-gitea/gitea/blob/03fce8f3d0cf3c180f06470257dc09a6c09ec5b0/tests/integration/pull_merge_test.go#L46 does not fail because it is required to supply the request form with `head_commit_id ` which will take us to ``` if expectedHeadCommitID != "" { trackingCommitID, _, err := mergeCtx.PrepareGitCmd(gitcmd.NewCommand("show-ref", "--hash").AddDynamicArguments(git.BranchPrefix + trackingBranch)).RunStdString(ctx) ``` it's included when calling merge from the UI but not from this test case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15007