OpenEugene / openboard

An open source switchboard, written in Elm and Go.
MIT License
21 stars 7 forks source link

Bug: Visiting /v/posts crashes the backend #137

Closed appins closed 3 years ago

appins commented 3 years ago

Expected Behavior

Visiting /v/posts should either display a page of unfiltered results or display some error (400 bad request?). The backend should continue running normally.

Actual Behavior

The backend crashes. Stack trace:

panic: runtime error: index out of range [0] with length 0

goroutine 74 [running]:
github.com/OpenEugene/openboard/back/internal/postsvc/internal/postdb.(*PostDB).findPosts(0xc00000e7a0, 0xb4a8e0, 0xc0002c7dd0, 0xc0002df310, 0xc0002ec0c0, 0x0, 0x0)
    /home/appins/openboard/back/internal/postsvc/internal/postdb/qrypost.go:121 +0xa26
github.com/OpenEugene/openboard/back/internal/postsvc/internal/postdb.(*PostDB).FndPosts(0xc00000e7a0, 0xb4a8e0, 0xc0002c7dd0, 0xc0002df310, 0xa3e300, 0x0, 0xb4ce80)
    /home/appins/openboard/back/internal/postsvc/internal/postdb/postdb.go:63 +0x6c
github.com/OpenEugene/openboard/back/internal/postsvc.(*PostSvc).FndPosts(0xc000059b80, 0xb4a8e0, 0xc0002c7dd0, 0xc0002df310, 0xc000059b80, 0xc0002c7dd0, 0xc000053a20)
    /home/appins/openboard/back/internal/postsvc/postsvc.go:60 +0x51
github.com/OpenEugene/openboard/back/internal/pb._Post_FndPosts_Handler(0xa3e300, 0xc000059b80, 0xb4a8e0, 0xc0002c7dd0, 0xc0002df2c0, 0x0, 0xb4a8e0, 0xc0002c7dd0, 0x0, 0x0)
    /home/appins/openboard/back/internal/pb/post.pb.go:882 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000110900, 0xb4f760, 0xc000111680, 0xc0002e0800, 0xc0000fb0e0, 0xf193a8, 0x0, 0x0, 0x0)
    /home/appins/go/pkg/mod/google.golang.org/grpc@v1.20.0/server.go:972 +0x486
google.golang.org/grpc.(*Server).handleStream(0xc000110900, 0xb4f760, 0xc000111680, 0xc0002e0800, 0x0)
    /home/appins/go/pkg/mod/google.golang.org/grpc@v1.20.0/server.go:1252 +0xd34
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000025790, 0xc000110900, 0xb4f760, 0xc000111680, 0xc0002e0800)
    /home/appins/go/pkg/mod/google.golang.org/grpc@v1.20.0/server.go:691 +0xa5
created by google.golang.org/grpc.(*Server).serveStreams.func1
    /home/appins/go/pkg/mod/google.golang.org/grpc@v1.20.0/server.go:689 +0xa5

Steps To Reproduce The Problem

  1. Start backend with ./openbsrv --dbpass=$OBPASS --migrate
  2. Visit http://localhost:4243/v/posts

Specifications

Additional Notes

I'd really like to learn and contribute to this project and would like to be the one to fix this issue, if that is possible.

appins commented 3 years ago

@daved and @codegold79 (and some others) watched me produce this error on stream.