-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
Handle post rendering errors to avoid bricking #3061
Conversation
Whether it's due to corrupted content, missing tags, caching issues, or other assorted reasons, post content can't be rendered. Currently, this results in an exception that crashes the entire forum and is hard to debug. Instead, we should log the error and show an indicator message that rendering has failed.
[ci skip] [skip ci]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! more safe erroring!
I wonder if we could have information on the frontend about the post failing to render so that we can have minimal visuals indicating a formatting failure rather than it looking like an ordinary post. Maybe if we were to add a $renderingFailed
property to the comment post model and add that to the serializer ?
We could, but that would make the formatter aware of what it's formatting, or require use-case-specific handling. That being said, supporting this is another good reason for moving this handling out of the general formatter and into the serializer. |
Ah I got overexcited and missed the PR description 🙈, I see it now.
Like I mentioned above, I don't think metadata is needed as much as just a simple boolean value to indicate a rendering failure to the frontend. A simple visual change would be clean and a more efficient indicator of failure alongside the text. So moving this to either the model method or the serializer makes sense. |
[ci skip] [skip ci]
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
[ci skip] [skip ci]
Co-authored-by: David Wheatley <hi@davwheat.dev>
[ci skip] [skip ci]
Fixes Part of flarum/issue-archive#85
Changes proposed in this pull request:
Whether it's due to corrupted content, missing tags, caching issues, or other assorted reasons, post content can't be rendered. Currently, this results in an exception that crashes the entire forum and is hard to debug. Instead, we should log the error and show an indicator message that rendering has failed.
Reviewers should focus on:
Is the Formatter class level the best place to do this? I also considered handling it directly under the relevant
CommentPost
method. The main benefit of handling per-call-site is that we could include some metadata (like the post ID) in the error message. However, we'd need to handle every possible use case, which is expensive and isn't worth it IMO.Also, any suggestions on better error text?
Screenshots
Confirmed
composer test
).Required changes: