Closed addpromax closed 11 months ago
[Flamego] PANIC: runtime error: index out of range [0] with length 0 /www/go/src/runtime/panic.go:113 (0x43601e) goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex}) /www/go/gopath/pkg/mod/github.com/aliyun/aliyun-oss-go-sdk@v2.2.4+incompatible/oss/conn.go:805 (0xe3248e) (urlMaker).Init: if host[0] == '[' && host[len(host)-1] == ']' { /www/go/gopath/pkg/mod/github.com/aliyun/aliyun-oss-go-sdk@v2.2.4+incompatible/oss/client.go:52 (0xe2bf04) New: err := url.Init(config.Endpoint, config.IsCname, config.IsUseProxy) /www/go/src/NekoBox/internal/storage/oss.go:27 (0xe35a76) UploadPictureToOSS: client, err := oss.New(conf.Upload.AliyunEndpoint, conf.Upload.AliyunAccessID, conf.Upload.AliyunAccessSecret) /www/go/src/NekoBox/route/user/profile.go:44 (0xe368c4) UpdateProfile: avatarURL, err = storage.UploadPictureToOSS(avatarFile, avatarFileHeader) /www/go/src/reflect/value.go:584 (0x4d1ce4) Value.call: call(frametype, fn, stackArgs, uint32(frametype.size), uint32(abid.retOffset), uint32(frameSize), ®Args) /www/go/src/reflect/value.go:368 (0x4d11db) Value.Call: return v.call("Call", in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:153 (0xc18a66) (injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:114 (0xc186b4) (injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/session@v1.2.1/session.go:185 (0xd59a5a) Sessioner.func2: c.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/handler.go:26 (0xc45dcc) ContextInvoker.Invoke: invoke(args[0].(Context)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/src/NekoBox/internal/tracing/flamego.go:53 (0xe3c943) Middleware.func1: c.Next() /www/go/src/reflect/value.go:584 (0x4d1ce4) Value.call: call(frametype, fn, stackArgs, uint32(frametype.size), uint32(abid.retOffset), uint32(frameSize), ®Args) /www/go/src/reflect/value.go:368 (0x4d11db) Value.Call: return v.call("Call", in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:153 (0xc18a66) (injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:114 (0xc186b4) (injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/recovery.go:149 (0xc47301) Recovery.func4: c.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:26 (0xc463e5) LoggerInvoker.Invoke: invoke(params[0].(Context), params[1].(log.Logger)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:74 (0xc46a46) Logger.func2: ctx.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:26 (0xc463e5) LoggerInvoker.Invoke: invoke(params[0].(Context), params[1].(log.Logger)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/router.go:253 (0xc4a0d6) (router).Route.func1: r.contextCreator(w, req, params, handlers, r.URLPath).run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/router.go:350 (0xc4b16f) (router).ServeHTTP: leaf.Handler()(w, req, route.Params{ /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/flame.go:135 (0xc455e6) (Flame).ServeHTTP: f.Router.ServeHTTP(w, r) /www/go/src/net/http/server.go:2947 (0x827f0b) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /www/go/src/net/http/server.go:1991 (0x8235e6) (conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /www/go/src/runtime/asm_amd64.s:1594 (0x468ce0) goexit: BYTE $0x90 // NOP [Flamego] 2023-04-14 15:45:06: Completed POST /user/profile/update 500 Internal Server Error in 22.073531ms
这是传头像报错
[Flamego] 2023-04-14 15:40:03: Started POST /user/profile/update for x [Flamego] 2023-04-14 15:40:03: Completed POST /user/profile/update 400 Bad Request in 6.607624ms
前台显示Bad Request: invalid CSRF token
所有的 POST 操作均提示这个问题吗?这是 CSRF Token 不正确。
想问下反向代理背后是有多个后端吗?Session 有配置 Redis 共享吗?
[Flamego] PANIC: runtime error: index out of range [0] with length 0 /www/go/src/runtime/panic.go:113 (0x43601e) goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex}) /www/go/gopath/pkg/mod/github.com/aliyun/aliyun-oss-go-sdk@v2.2.4+incompatible/oss/conn.go:805 (0xe3248e) (urlMaker).Init: if host[0] == '[' && host[len(host)-1] == ']' { /www/go/gopath/pkg/mod/github.com/aliyun/aliyun-oss-go-sdk@v2.2.4+incompatible/oss/client.go:52 (0xe2bf04) New: err := url.Init(config.Endpoint, config.IsCname, config.IsUseProxy) /www/go/src/NekoBox/internal/storage/oss.go:27 (0xe35a76) UploadPictureToOSS: client, err := oss.New(conf.Upload.AliyunEndpoint, conf.Upload.AliyunAccessID, conf.Upload.AliyunAccessSecret) /www/go/src/NekoBox/route/user/profile.go:44 (0xe368c4) UpdateProfile: avatarURL, err = storage.UploadPictureToOSS(avatarFile, avatarFileHeader) /www/go/src/reflect/value.go:584 (0x4d1ce4) Value.call: call(frametype, fn, stackArgs, uint32(frametype.size), uint32(abid.retOffset), uint32(frameSize), ®Args) /www/go/src/reflect/value.go:368 (0x4d11db) Value.Call: return v.call("Call", in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:153 (0xc18a66) (injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:114 (0xc186b4) (injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/session@v1.2.1/session.go:185 (0xd59a5a) Sessioner.func2: c.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/handler.go:26 (0xc45dcc) ContextInvoker.Invoke: invoke(args[0].(Context)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/src/NekoBox/internal/tracing/flamego.go:53 (0xe3c943) Middleware.func1: c.Next() /www/go/src/reflect/value.go:584 (0x4d1ce4) Value.call: call(frametype, fn, stackArgs, uint32(frametype.size), uint32(abid.retOffset), uint32(frameSize), ®Args) /www/go/src/reflect/value.go:368 (0x4d11db) Value.Call: return v.call("Call", in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:153 (0xc18a66) (injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:114 (0xc186b4) (injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/recovery.go:149 (0xc47301) Recovery.func4: c.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:26 (0xc463e5) LoggerInvoker.Invoke: invoke(params[0].(Context), params[1].(log.Logger)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:160 (0xc436bc) (context).Next: c.run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:74 (0xc46a46) Logger.func2: ctx.Next() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/logger.go:26 (0xc463e5) LoggerInvoker.Invoke: invoke(params[0].(Context), params[1].(log.Logger)) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:134 (0xc187d4) (injector).fastInvoke: return f.Invoke(in) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/inject/inject.go:112 (0xc186fc) (injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/context.go:210 (0xc439f3) (context).run: vals, err := c.Invoke(h) /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/router.go:253 (0xc4a0d6) (router).Route.func1: r.contextCreator(w, req, params, handlers, r.URLPath).run() /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/router.go:350 (0xc4b16f) (router).ServeHTTP: leaf.Handler()(w, req, route.Params{ /www/go/gopath/pkg/mod/github.com/flamego/flamego@v1.7.0/flame.go:135 (0xc455e6) (Flame).ServeHTTP: f.Router.ServeHTTP(w, r) /www/go/src/net/http/server.go:2947 (0x827f0b) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /www/go/src/net/http/server.go:1991 (0x8235e6) (conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /www/go/src/runtime/asm_amd64.s:1594 (0x468ce0) goexit: BYTE $0x90 // NOP [Flamego] 2023-04-14 15:45:06: Completed POST /user/profile/update 500 Internal Server Error in 22.073531ms
这个看来是阿里云 OSS SDK 上传报的错,请检查下本地阿里云的 AK SK 配置是否正确。
[Flamego] 2023-04-14 15:40:03: Started POST /user/profile/update for x [Flamego] 2023-04-14 15:40:03: Completed POST /user/profile/update 400 Bad Request in 6.607624ms
前台显示Bad Request: invalid CSRF token