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 Handling #15

Closed
lmangani opened this issue Apr 13, 2023 · 4 comments
Closed

Panic Handling #15

lmangani opened this issue Apr 13, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lmangani
Copy link
Collaborator

lmangani commented Apr 13, 2023

Generic errors are handled correctly, ie:

import "array"
import "runtime"
array.from(rows: [{version: runtime.version() - "string" }])
{"code":"invalid","message":"error @3:29-3:57: string is not Subtractable"}

This is fine.

Library panic events are not correctly returned to the client, ie (float/string panic inside a column):

import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
 
|> filter(fn: (r) => r._measurement == "average_temperature")
|> map(fn: (r) => ({r with celsius: (( r._value - 32.0) * 5.0 / 9.0)} ))
{"message":"Internal Server Error"}

The actual error is only available in the debug log on the server side:

{"time":"2023-04-13T13:34:33.304082423Z","level":"-","prefix":"echo","file":"recover.go","line":"92","message":"[PANIC RECOVER] runtime error [@5:4-5:62](https://matrix.to/#/@5:4-5:62): filter: type conflict: float != string goroutine 24 [running]:\[ngithub.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1.1()\n\t/home/runner/go/pkg/mod/github.com/labstack/echo/v4@v4.2.1/middleware/recover.go:77](http://ngithub.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1.1()/n/t/home/runner/go/pkg/mod/github.com/labstack/echo/v4@v4.2.1/middleware/recover.go:77) +0x10d\npanic({0x19c7760, 0xc0016e8bc0})\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:838 +0x207\nmain.exec({0xc001690f00, 0x13e})\n\t/home/runner/work/fluXpipe/fluXpipe/fluxpipe-server.go:151 +0x737\nmain.postQuery({0x1ecc518, 0xc00079d7c0})\n\t/home/runner/work/fluXpipe/fluXpipe/fluxpipe-server.go:97 +0x5d3\[ngithub.com/labstack/echo/v4.(*Echo).add.func1({0x1ecc518,](http://ngithub.com/labstack/echo/v4.(*Echo).add.func1(%7B0x1ecc518,) 0xc00079d7c0})\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/echo.go:536](http://github.com/labstack/echo/v4@v4.2.1/echo.go:536) +0x51\[ngithub.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1({0x1ecc518,](http://ngithub.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(%7B0x1ecc518,) 0xc00079d7c0})\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/middleware/cors.go:186](http://github.com/labstack/echo/v4@v4.2.1/middleware/cors.go:186) +0xe98\[ngithub.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1({0x1ecc518,](http://ngithub.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1(%7B0x1ecc518,) 0xc00079d7c0})\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/middleware/recover.go:98](http://github.com/labstack/echo/v4@v4.2.1/middleware/recover.go:98) +0xf8\[ngithub.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x1ecc518,](http://ngithub.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1(%7B0x1ecc518,) 0xc00079d7c0})\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/middleware/logger.go:117](http://github.com/labstack/echo/v4@v4.2.1/middleware/logger.go:117) +0xe2\[ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000b25200,](http://ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000b25200,) {0x1eb9e50?, 0xc0004f4fc0}, 0xc0018a2000)\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/echo.go:646](http://github.com/labstack/echo/v4@v4.2.1/echo.go:646) +0x3bc\nnet/http.serverHandler.ServeHTTP({0x1eb5cc0?}, {0x1eb9e50, 0xc0004f4fc0}, 0xc0018a2000)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/http/server.go:2916 +0x43b\nnet/http.(*conn).serve(0xc00079d720, {0x1ebada0, 0xc001830990})\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/http/server.go:1966 +0x5d7\ncreated by net/http.(*Server).Serve\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/http/server.go:3071 +0x4db\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x7f2693a80d90, 0x72)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/runtime/netpoll.go:302 +0x89\ninternal/poll.(*pollDesc).wait(0xc001821b80?, 0xc0000021a0?, 0x0)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_poll_runtime.go:83 +0x32\ninternal/poll.(*pollDesc).waitRead(...)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_poll_runtime.go:88\ninternal/poll.(*FD).Accept(0xc001821b80)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_unix.go:614 +0x22c\nnet.(*netFD).accept(0xc001821b80)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/fd_unix.go:172 +0x35\nnet.(*TCPListener).accept(0xc0016e7968)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/tcpsock_posix.go:139 +0x28\nnet.(*TCPListener).AcceptTCP(0xc0016e7968)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/tcpsock.go:275 +0x3d\[ngithub.com/labstack/echo/v4.tcpKeepAliveListener.Accept({0x44e0c0?})\n\t/home/runner/go/pkg/mod/github.com/labstack/echo/v4@v4.2.1/echo.go:955](http://ngithub.com/labstack/echo/v4.tcpKeepAliveListener.Accept(%7B0x44e0c0?})\n\t/home/runner/go/pkg/mod/github.com/labstack/echo/v4@v4.2.1/echo.go:955) +0x1d\nnet/http.(*Server).Serve(0xc0004f4c40, {0x1eb90d0, 0xc000010650})\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/net/http/server.go:3039 +0x385\[ngithub.com/labstack/echo/v4.(*Echo).Start(0xc000b25200,](http://ngithub.com/labstack/echo/v4.(*Echo).Start(0xc000b25200,) {0xc0017f5638, 0x5})\n\t/home/runner/go/pkg/mod/[github.com/labstack/echo/v4@v4.2.1/echo.go:663](http://github.com/labstack/echo/v4@v4.2.1/echo.go:663) +0xc7\nmain.main()\n\t/home/runner/work/fluXpipe/fluXpipe/fluxpipe-server.go:221 +0x85a\n\ngoroutine 7 [select]:\[ngo.opencensus.io/stats/view.(*worker).start(0xc0003c8180)\n\t/home/runner/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:276](http://ngo.opencensus.io/stats/view.(*worker).start(0xc0003c8180)/n/t/home/runner/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:276) +0xad\ncreated by [go.opencensus.io/stats/view.init.0\n\t/home/runner/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:34](http://go.opencensus.io/stats/view.init.0/n/t/home/runner/go/pkg/mod/go.opencensus.io@v0.23.0/stats/view/worker.go:34) +0x8d\n\ngoroutine 26 [IO wait]:\ninternal/poll.runtime_pollWait(0x7f2693a80ca0, 0x72)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/runtime/netpoll.go:302 +0x89\ninternal/poll.(*pollDesc).wait(0xc001821c00?, 0xc001830a91?, 0x0)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_poll_runtime.go:83 +0x32\ninternal/poll.(*pollDesc).waitRead(...)\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_poll_runtime.go:88\ninternal/poll.(*FD).Read(0xc001821c00, {0xc001830a91, 0x1, 0x1})\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/internal/poll/fd_unix.go:167 +0x25a\nnet.(*netFD).Read(0xc001821c00, {0xc001830a91?, 0xc00182f998?, 0xc0004ca768?})\n\t/opt/hostedtoolcache/go/1.\n"}

or simply

runtime error [@5:4-5:62](https://matrix.to/#/@5:4-5:62): filter: type conflict: float != string

The library panic message (or at least the runtime error string) should be returned to the client.
Since this is not a panic/err of the API handler, the output is uncaught.

@lmangani lmangani added enhancement New feature or request help wanted Extra attention is needed labels Apr 13, 2023
@adubovikov
Copy link
Contributor


defer func() {
		if r := recover(); r != nil {
			logger.Logger.Errorf("Panic: %v,\n%s", r, debug.Stack())
			return
		}
	}()

@lmangani
Copy link
Collaborator Author

This is the handler where we need to capture this panic into an http response.

@lmangani
Copy link
Collaborator Author

Testing fix in issue #16

@lmangani
Copy link
Collaborator Author

resolved in latest release v0.194.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants