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

回答時にエラーが発生する #86

Open
K-shir0 opened this issue Dec 26, 2022 · 4 comments
Open

回答時にエラーが発生する #86

K-shir0 opened this issue Dec 26, 2022 · 4 comments
Labels
P1 優先度: 高 確実に実装するものなど

Comments

@K-shir0
Copy link
Member

K-shir0 commented Dec 26, 2022

URL POST

http://localhost:8080/api/problems/30caf019-3a47-4011-b600-d68c092a65b5/answers

リクエストボディ

{"user_group_id":"5240c41a-39bc-4218-af20-4b2cf7c034ae","problem_id":"30caf019-3a47-4011-b600-d68c092a65b5","body":"aaaa"}

エラー

ictsc-rikka-rikka-1  | runtime error: invalid memory address or nil pointer dereference
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/getsentry/[email protected]/gin/sentrygin.go:72 (0xc3c192)
ictsc-rikka-rikka-1  |  (*handler).recoverWithSentry: panic(err)
ictsc-rikka-rikka-1  | /usr/local/go/src/runtime/panic.go:965 (0x438298)
ictsc-rikka-rikka-1  |  gopanic: done = runOpenDeferFrame(gp, d)
ictsc-rikka-rikka-1  | /usr/local/go/src/runtime/panic.go:212 (0x43669a)
ictsc-rikka-rikka-1  |  panicmem: panic(memoryError)
ictsc-rikka-rikka-1  | /usr/local/go/src/runtime/signal_unix.go:734 (0x44f2f2)
ictsc-rikka-rikka-1  |  sigpanic: panicmem()
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/service/answer.go:94 (0x7cb609)
ictsc-rikka-rikka-1  |  (*AnswerService).Create: body, err := io.ReadAll(resp.Body)
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/controller/answer.go:33 (0x7d4bda)
ictsc-rikka-rikka-1  |  (*AnswerController).Create: ans, err := c.answerService.Create(&service.CreateAnswerRequest{
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/delivery/http/handler/answer.go:48 (0xb8250c)
ictsc-rikka-rikka-1  |  (*AnswerHandler).Create: res, err := h.answerController.Create(group, problem_id, req)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb8071c)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/delivery/http/middleware/auth.go:54 (0xb806fc)
ictsc-rikka-rikka-1  |  Auth.func1: ctx.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb8071c)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/delivery/http/middleware/auth.go:54 (0xb806fc)
ictsc-rikka-rikka-1  |  Auth.func1: ctx.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb7fe21)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/pkg/delivery/http/middleware/error.go:19 (0xb7fe01)
ictsc-rikka-rikka-1  |  (*ErrorMiddleware).HandleError: ctx.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xbe1df8)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/zsais/[email protected]/middleware.go:364 (0xbe1dd8)
ictsc-rikka-rikka-1  |  (*Prometheus).HandlerFunc.func1: c.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb7f015)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-contrib/[email protected]/sessions.go:52 (0xb7effd)
ictsc-rikka-rikka-1  |  Sessions.func1: c.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xc3bf50)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/getsentry/[email protected]/gin/sentrygin.go:57 (0xc3bf38)
ictsc-rikka-rikka-1  |  (*handler).handle: ctx.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xc3ee59)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/src/ictsc-rikka/cmd/rikka/main.go:186 (0xc3ee39)
ictsc-rikka-rikka-1  |  main.func1: ctx.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb7c8f9)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99 (0xb7c8e0)
ictsc-rikka-rikka-1  |  CustomRecoveryWithWriter.func1: c.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb7b9d3)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0xb7b992)
ictsc-rikka-rikka-1  |  LoggerWithConfig.func1: c.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0xb71e89)
ictsc-rikka-rikka-1  |  (*Context).Next: c.handlers[c.index](c)
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:489 (0xb71e6f)
ictsc-rikka-rikka-1  |  (*Engine).handleHTTPRequest: c.Next()
ictsc-rikka-rikka-1  | /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:445 (0xb7195b)
ictsc-rikka-rikka-1  |  (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
ictsc-rikka-rikka-1  | /usr/local/go/src/net/http/server.go:2868 (0x7977a2)
ictsc-rikka-rikka-1  |  serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
ictsc-rikka-rikka-1  | /usr/local/go/src/net/http/server.go:1933 (0x792bcc)
ictsc-rikka-rikka-1  |  (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
ictsc-rikka-rikka-1  | /usr/local/go/src/runtime/asm_amd64.s:1371 (0x46f080)
ictsc-rikka-rikka-1  |  goexit: BYTE    $0x90   // NOP
@K-shir0 K-shir0 added the P1 優先度: 高 確実に実装するものなど label Dec 26, 2022
@K-shir0 K-shir0 self-assigned this Dec 26, 2022
@K-shir0 K-shir0 changed the title 回答を押した時にエラーが発生する 回答時にエラーが発生する Dec 26, 2022
@x86taka
Copy link
Member

x86taka commented Dec 26, 2022

Slackのwebhookに失敗したときの処理が適当だからみたいなので、なんらかのhook用のURLをconfigに追加すると動きそうです。

@K-shir0
Copy link
Member Author

K-shir0 commented Dec 27, 2022

素早い原因の特定ありがとうございます。おっしゃるとおりで適当なURL追加したら動きました

@K-shir0
Copy link
Member Author

K-shir0 commented Dec 27, 2022

エラーとか流れてこないのでまずそう

該当箇所

{
param := struct {
Text string `json:"text"`
Channel string `json:"channel"`
}{
Text: "<https://contest.mgmt.ictsc.net/#/problems/"+ req.ProblemID.String() + "|新着解答> 問題名:" + problem.Title + " チーム名:" + req.UserGroup.Name + "",
Channel: "#prob-" + strings.ToLower(problem.Code),
}
json_str, err := json.Marshal(param)
if err != nil { fmt.Println(err.Error()) }
fmt.Println(string(json_str))
resp, err := http.Post(s.webhook,"application/json",bytes.NewBuffer(json_str))
if err != nil { fmt.Println(err.Error()) }
body, err := io.ReadAll(resp.Body)
if err != nil { fmt.Println(err.Error()) }
fmt.Println(string(body))
resp.Body.Close()
}

@x86taka
Copy link
Member

x86taka commented Dec 28, 2022

今コメント気がついた..!
エラーが流れてこない..?

Slackのwebhookが失敗したときに回答ができないのはまずいよね

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 優先度: 高 確実に実装するものなど
Projects
None yet
Development

No branches or pull requests

3 participants