Skip to content

Commit

Permalink
fix: nil reference
Browse files Browse the repository at this point in the history
  • Loading branch information
GentikSolm committed Dec 5, 2024
1 parent 72fb976 commit c376e1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ func main() {
cc := c.(*Context)
defer cc.log.Sync()
request, err := preprocessOpenaiRequest(cc, db)
cc.log.Info("/api/chat/completions - %d\n", request.UserId)
if err != nil {
error := err.(*RequestError)
cc.log.Error(err)
return cc.String(error.StatusCode, error.Err.Error())
}
cc.log.Info("/api/chat/completions - %d\n", request.UserId)
request.Endpoint = "CHAT"
res, err := queryMiners(cc, request.Body, "/v1/chat/completions", request.Miner)
go saveRequest(db, res, *request, cc.log)
Expand Down Expand Up @@ -135,12 +135,12 @@ func main() {
cc := c.(*Context)
defer cc.log.Sync()
request, err := preprocessOpenaiRequest(cc, db)
cc.log.Info("/api/completions - %d\n", request.UserId)
if err != nil {
error := err.(*RequestError)
cc.log.Error(err)
return cc.String(error.StatusCode, error.Err.Error())
}
cc.log.Info("/api/completions - %d\n", request.UserId)
request.Endpoint = "COMPLETION"
res, err := queryMiners(cc, request.Body, "/v1/completions", request.Miner)

Expand Down
21 changes: 21 additions & 0 deletions api/tmp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"level": "error",
"ts": 1733422192.0423977,
"caller": "app/server.go:83",
"msg": "Api Panic",
"error": "runtime error: invalid memory address or nil pointer dereference",
"stacktrace": "main.main.func2
/app/server.go:83\nmain.main.RecoverWithConfig.func6.1.1
/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/recover.go:105\nruntime.gopanic
/usr/local/go/src/runtime/panic.go:785\nruntime.panicmem
/usr/local/go/src/runtime/panic.go:262\nruntime.sigpanic
/usr/local/go/src/runtime/signal_unix.go:917\nmain.main.func3
/app/server.go:105\ngithub.com/labstack/echo/v4.(*Echo).add.func1
/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:582\nmain.main.RecoverWithConfig.func6.1
/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/recover.go:131\nmain.main.func1.1
/app/server.go:77\ngithub.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1
/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/cors.go:204\ngithub.com/labstack/echo/v4.(*Echo).ServeHTTP
/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:669\nnet/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:3210\nnet/http.(*conn).serve
/usr/local/go/src/net/http/server.go:2092"
}

0 comments on commit c376e1b

Please sign in to comment.