Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when echo HTTPErrorHandler is triggered #59

Open
BapiGso opened this issue Apr 10, 2024 · 0 comments
Open

panic when echo HTTPErrorHandler is triggered #59

BapiGso opened this issue Apr 10, 2024 · 0 comments

Comments

@BapiGso
Copy link

BapiGso commented Apr 10, 2024

package main

import (
	"github.com/CAFxX/httpcompression"
	"github.com/labstack/echo/v4"
)

func main()  {
	e:=echo.New()
	adapter, err := httpcompression.DefaultAdapter()
	if err != nil {
		return
	}
	e.Use(echo.WrapMiddleware(adapter))
	e.Start(":1323")
}

Use the above code, and then access an unregistered path to trigger HTTPErrorHandler and report the following error:

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.11.4
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O\
⇨ http server started on [::]:1323
echo: http: panic serving 127.0.0.1:64345: runtime error: invalid memory address or nil pointer dereference
goroutine 10 [running]:
net/http.(*conn).serve.func1()
	xxx/sdk/go1.21.0/src/net/http/server.go:1868 +0xb9
panic({0x11aa500?, 0x14c6d50?})
	xxx/sdk/go1.21.0/src/runtime/panic.go:920 +0x270
github.com/CAFxX/httpcompression.(*compressWriter).Header(0xc00008f920?)
	<autogenerated>:1 +0x1e
github.com/labstack/echo/v4.(*Response).Header(...)
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/response.go:36
github.com/labstack/echo/v4.(*context).writeContentType(0x10321b9?, {0x12069cd, 0x1f})
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/context.go:229 +0x30
github.com/labstack/echo/v4.(*context).json(0xc0000600a0, 0x194, {0x11abba0, 0xc00001ec30}, {0x0, 0x0})
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/context.go:492 +0x45
github.com/labstack/echo/v4.(*context).JSON(0xc0000600a0, 0xc00001ec30?, {0x11abba0, 0xc00001ec30})
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/context.go:502 +0xc7
github.com/labstack/echo/v4.(*Echo).DefaultHTTPErrorHandler(0xc000134240, {0x1281940, 0xc00001ed80?}, {0x1287648, 0xc0000600a0})
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:460 +0x46c
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000134240, {0x1283820?, 0xc0000942a0}, 0xc000518100)
	xxx/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:670 +0x3bb
net/http.serverHandler.ServeHTTP({0xc00001ea50?}, {0x1283820?, 0xc0000942a0?}, 0x6?)
	xxx/sdk/go1.21.0/src/net/http/server.go:2938 +0x8e
net/http.(*conn).serve(0xc00012c120, {0x1283d50, 0xc00051a2d0})
	xxx/sdk/go1.21.0/src/net/http/server.go:2009 +0x5f4
created by net/http.(*Server).Serve in goroutine 1
	xxx/sdk/go1.21.0/src/net/http/server.go:3086 +0x5cb
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

No branches or pull requests

1 participant