Panic: runtime error: index out of range [0] with length 0 with drone 1.9.1 and Bitbucket server v6.10.5

Hi

I’m trying to get drone running with Bitbucket Server v6.10.5.

When using drone 1.10.1 I can’t activate reporsitories as reported here: https://github.com/drone/go-scm/issues/88

When using drone 1.9.1 creating a new build fails with the following panic in the drone server.

Panic: runtime error: index out of range [0] with length 0
goroutine 140 [running]:
runtime/debug.Stack(0x3b, 0x0, 0x0)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9d
runtime/debug.PrintStack()
	/usr/local/go/src/runtime/debug/stack.go:16 +0x22
github.com/go-chi/chi/middleware.Recoverer.func1.1(0xc000a65500, 0x1eae6c0, 0xc00034c9a0)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/middleware/recoverer.go:28 +0x1b6
panic(0x19f6080, 0xc0003545a0)
	/usr/local/go/src/runtime/panic.go:969 +0x166
github.com/drone/go-scm/scm/driver/stash.(*Error).Error(0xc00033c0e0, 0x0, 0xc0008aafb8)
	/go/pkg/mod/github.com/drone/go-scm@v1.7.1-0.20200621203823-3731ec1f1136/scm/driver/stash/stash.go:133 +0x41
github.com/drone/drone/handler/api/render.ErrorCode(0x1eae6c0, 0xc00034c9a0, 0x1e75920, 0xc00033c0e0, 0x194)
	/drone/src/handler/api/render/render.go:55 +0x35
github.com/drone/drone/handler/api/render.NotFound(...)
	/drone/src/handler/api/render/render.go:79
github.com/drone/drone/handler/api/repos/builds.HandleCreate.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65d00)
	/drone/src/handler/api/repos/builds/create.go:73 +0xa95
net/http.HandlerFunc.ServeHTTP(0xc000231ae0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65d00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/drone/drone/handler/api/acl.CheckAccess.func1.1(0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/drone/src/handler/api/acl/check.go:140 +0x91d
net/http.HandlerFunc.ServeHTTP(0xc000577290, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*ChainHandler).ServeHTTP(0xc0000e7c80, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/chain.go:31 +0x52
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0003b6300, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc00003e790, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc0003b6300, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:69 +0x4f3
github.com/go-chi/chi.(*Mux).Mount.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:291 +0x11b
net/http.HandlerFunc.ServeHTTP(0xc00037dd00, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0003b60c0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc00003e710, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/drone/drone/handler/api/acl.CheckAccess.func1.1(0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/drone/src/handler/api/acl/check.go:99 +0x10c1
net/http.HandlerFunc.ServeHTTP(0xc000577020, 0x1eae6c0, 0xc00034c9a0, 0xc000a65c00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/drone/drone/handler/api/acl.InjectRepository.func1.1(0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/drone/src/handler/api/acl/repo.go:133 +0xf0a
net/http.HandlerFunc.ServeHTTP(0xc000231a40, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc0003b60c0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:69 +0x4f3
github.com/go-chi/chi.(*Mux).Mount.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:291 +0x11b
net/http.HandlerFunc.ServeHTTP(0xc0000c08e0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0003b6000, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc00003e6d0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc0003b6000, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:69 +0x4f3
github.com/go-chi/chi.(*Mux).Mount.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:291 +0x11b
net/http.HandlerFunc.ServeHTTP(0xc0000c0a20, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).routeHTTP(0xc00004bf80, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc00003eb30, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/cors.(*Cors).Handler.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/go/pkg/mod/github.com/go-chi/cors@v1.0.0/cors.go:199 +0x183
net/http.HandlerFunc.ServeHTTP(0xc0000c0a40, 0x1eae6c0, 0xc00034c9a0, 0xc000a65b00)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/drone/drone/handler/api/auth.HandleAuthentication.func1.1(0x1eae6c0, 0xc00034c9a0, 0xc000a65600)
	/drone/src/handler/api/auth/auth.go:51 +0x467
net/http.HandlerFunc.ServeHTTP(0xc0001a0c00, 0x1eae6c0, 0xc00034c9a0, 0xc000a65600)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/drone/drone/logger.Middleware.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/drone/src/logger/handler.go:36 +0x373
net/http.HandlerFunc.ServeHTTP(0xc0000c0a80, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi/middleware.NoCache.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/middleware/nocache.go:54 +0x2a0
net/http.HandlerFunc.ServeHTTP(0xc0000c0aa0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi/middleware.Recoverer.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/middleware/recoverer.go:35 +0x83
net/http.HandlerFunc.ServeHTTP(0xc0000c0ac0, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc00004bf80, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:69 +0x4f3
github.com/go-chi/chi.(*Mux).Mount.func1(0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:291 +0x11b
net/http.HandlerFunc.ServeHTTP(0xc0000c1c40, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).routeHTTP(0xc00004bf20, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc00003e640, 0x1eae6c0, 0xc00034c9a0, 0xc000a65500)
	/usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc00004bf20, 0x1eae6c0, 0xc00034c9a0, 0xc000a65400)
	/go/pkg/mod/github.com/go-chi/chi@v3.3.3+incompatible/mux.go:81 +0x2b2
net/http.serverHandler.ServeHTTP(0xc00017c380, 0x1eae6c0, 0xc00034c9a0, 0xc000a65400)
	/usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc000a76640, 0x1eb3680, 0xc00002c480)
	/usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2933 +0x35c

Do you have any idea on how to fix this?

Kind Regards,
Marc

let’s move the discussion to existing threads:

http://discuss.harness.io/t/support-for-bitbucket-server-stash-pull-request-modified-events/6897/10