HomePhabricator
Diffusion Comm d723fb3230a2

[lib] Fix fatal error where empty code blocks crash

Description

[lib] Fix fatal error where empty code blocks crash

Summary:
There's a pretty fatal error where an empty code block will
trigger the throw Error statement. I suspect that it's because the
object for the message is { type: 'codeBlock', content: '\n' }.

It makes sense to just return the node if we have nothing to traverse within.

https://linear.app/comm/issue/ENG-2438/unexpected-markdown-in-dec-9-daily-update-message-causing-native-app

Test Plan:
Reproduced the message that causes the crash, alongside other more edge cases. Didn't experience a crash

Screenshot 2022-12-08 at 9.58.04 PM.png (206×608 px, 28 KB)

Screenshot 2022-12-08 at 9.58.15 PM.png (302×524 px, 48 KB)

Reviewers: ginsu, atul, tomek, ashoat

Reviewed By: ginsu, ashoat

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D5849

Details

Provenance
rohanAuthored on Dec 14 2022, 3:14 PM
Reviewer
ginsu
Differential Revision
D5849: [lib] Fix fatal error where empty code blocks crash
Parents
rCOMM71a3b71d0cda: [Nix] Package blob
Branches
Unknown
Tags
Unknown