Bug: crash when openning some messages
benjamin-voisin opened this issue · comments
Benjamin Voisin commented
When I open (or send) messages like
+ a
+ b
Dissent crashes instantly. This is very problematic as, when you reopen dissent, it opens the same discussion, and so, crashes instantly.
It seems that the issue come from the parsing of the message, I got this error :
2024/04/22 12:26:56 Parsing content: "+ a\n+ b"
panic: interface conversion: ast.Node is *ast.Paragraph, not *ast.ListItem [recovered]
panic: closure error: unexpected panic caught: interface conversion: ast.Node is *ast.Paragraph, not *ast.ListItem
So to me, there are 2 issues :
- The parser fails with lists starting with "+"
- The whole program crashes when a message cannot be parsed. It could probably print an error message "error: this message cannot be shown".
Diamond commented
What's the stack trace for this?
Diamond commented
Nevermind, a test case has been added. I'll look into this.
--- FAIL: TestParses (0.00s)
panic: interface conversion: ast.Node is *ast.Paragraph, not *ast.ListItem [recovered]
panic: interface conversion: ast.Node is *ast.Paragraph, not *ast.ListItem
goroutine 39 [running]:
testing.tRunner.func1.2({0x627740, 0xc000294870})
/nix/store/j3hjjj2cad67jlf0mvl90j3d23815259-go-diamondburned-1.22.1/share/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
/nix/store/j3hjjj2cad67jlf0mvl90j3d23815259-go-diamondburned-1.22.1/share/go/src/testing/testing.go:1634 +0x377
panic({0x627740?, 0xc000294870?})
/nix/store/j3hjjj2cad67jlf0mvl90j3d23815259-go-diamondburned-1.22.1/share/go/src/runtime/panic.go:770 +0x132
github.com/yuin/goldmark/parser.lastOffset(...)
/home/diamond/.go/pkg/mod/github.com/yuin/goldmark@v1.5.6/parser/list.go:107
github.com/yuin/goldmark/parser.(*listParser).Continue(0xc0002ba5b0?, {0x6e24d0, 0xc0002be990}, {0x6e1038, 0xc0002ba5b0}, {0x6e1320, 0xc0002ba620})
/home/diamond/.go/pkg/mod/github.com/yuin/goldmark@v1.5.6/parser/list.go:195 +0x4c5
github.com/yuin/goldmark/parser.(*parser).parseBlocks(0xc0002fca08, {0x6e1990, 0xc0002be900}, {0x6e1038, 0xc0002ba5b0}, {0x6e1320, 0xc0002ba620})
/home/diamond/.go/pkg/mod/github.com/yuin/goldmark@v1.5.6/parser/parser.go:1093 +0x5b9
github.com/yuin/goldmark/parser.(*parser).Parse(0xc0002fca08, {0x6e1038, 0xc0002ba5b0}, {0x0, 0x0, 0x4ce800?})
/home/diamond/.go/pkg/mod/github.com/yuin/goldmark@v1.5.6/parser/parser.go:876 +0x153
github.com/diamondburned/ningen/v3/discordmd.Parse({0xc000288198, 0x7, 0x8}, {0x0, 0x0, 0x0})
/home/diamond/Scripts/ningen/discordmd/md.go:54 +0x288
github.com/diamondburned/ningen/v3/discordmd.TestParses(0xc0002aa4e0?)
/home/diamond/Scripts/ningen/discordmd/md_test.go:29 +0x91
testing.tRunner(0xc0002aa4e0, 0x6691c0)
/nix/store/j3hjjj2cad67jlf0mvl90j3d23815259-go-diamondburned-1.22.1/share/go/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 1
/nix/store/j3hjjj2cad67jlf0mvl90j3d23815259-go-diamondburned-1.22.1/share/go/src/testing/testing.go:1742 +0x390
FAIL github.com/diamondburned/ningen/v3/discordmd 0.010s
FAIL
exit status 1
Sure hope this isn't an upstream library issue!