Skip to content

Setting ENABLE_GZIP=true makes swagger API URL 500 (NPE panic) #19839

Closed
@wxiaoguang

Description

@wxiaoguang

Steps:

  1. set server.ENABLE_GZIP=true
  2. visit http://localhost:3000/api/swagger
  3. panic
PANIC: interface conversion: interface {} is nil, not *context.Context
/usr/local/go/src/runtime/iface.go:262 (0x400eae9)
	panicdottypeE: panic(&TypeAssertionError{iface, have, want, ""})
/Users/user/work/gitea/modules/context/context.go:622 (0x61204b1)
	GetContext: return req.Context().Value(contextKey).(*Context)
/Users/user/work/gitea/modules/web/wrap_convert.go:43 (0x6882ac4)
	convertHandler.func3: ctx := context.GetContext(req)
/Users/user/work/gitea/modules/web/wrap.go:41 (0x688068e)
	wrapInternal.func1: done, deferrable := handler(resp, req, others...)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/!n!y!times/gziphandler@v1.1.1/gzip.go:338 (0x6bf25da)
	GzipHandlerWithOpts.func1.1: h.ServeHTTP(gw, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/modules/web/wrap_convert.go:95 (0x6882390)
	convertHandler.func9: t(next).ServeHTTP(resp, req)
/Users/user/work/gitea/modules/web/wrap.go:41 (0x688068e)
	wrapInternal.func1: done, deferrable := handler(resp, req, others...)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:442 (0x5b175fd)
	(*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/routers/web/base.go:173 (0x6bf6997)
	Recovery.func1.1: next.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20211218221615-e3605d8b28b8/session.go:257 (0x58bb116)
	Sessioner.func1.1: next.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/modules/web/wrap.go:110 (0x6881827)
	WrapWithPrefix.func1.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:71 (0x5b14799)
	(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:314 (0x5b16b23)
	(*Mux).Mount.func1: handler.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:442 (0x5b175fd)
	(*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/routers/common/middleware.go:79 (0x69286d7)
	Middlewares.func2.1: next.ServeHTTP(resp, req)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/modules/web/routing/logger_manager.go:123 (0x687c61e)
	(*requestRecordsManager).handler.func1: next.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/middleware/strip.go:30 (0x6923aa1)
	StripSlashes.func1: next.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x691e29b)
	ForwardedHeaders.func1.1: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/work/gitea/routers/common/middleware.go:32 (0x69284b1)
	Middlewares.func1.1: next.ServeHTTP(context.NewResponse(resp), req.WithContext(ctx))
/usr/local/go/src/net/http/server.go:2084 (0x47f7c62)
	HandlerFunc.ServeHTTP: f(w, r)
/Users/user/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:88 (0x5b14927)
	(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/Users/user/work/gitea/modules/web/route.go:200 (0x687f3c5)
	(*Route).ServeHTTP: r.R.ServeHTTP(w, req)
/usr/local/go/src/net/http/server.go:2916 (0x47fca93)
	serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1966 (0x47f6abb)
	(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1571 (0x4074080)
	goexit: BYTE	$0x90	// NOP

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions