Project Information
- Repository: https://github.com/busyorg/busy
- Project Name: Busy
- GitHub Issue: https://github.com/busyorg/busy/issues/2019
Expected behavior
When a post doesn't contain any json_metadata the site should continue to work as normal.
Actual behavior
Any piece of code that tries to read a property of the JSON object when it's null will cause an error and the app will crash.
An example is
if (_.indexOf(postMetaData.app, 'steemit') === 0) {
canonicalHost = 'https://steemit.com';
}
postMetaData.app
will cause an error which is what can be seen in the developer console.
How to reproduce
If you got to a post with no json_metadata like this one @steemed/dan-cant-censor-with-51pct the whole page crashes. If you go to a user who's reblogged it such as @berniesanders the page crashes once that post is rendered
An example of a post with empty metadata
Recording Of The Bug
Crash when you visit the post
Crash when you visit the blog of someone who's reblogged the post
Possible solution
The easiest solution is to check whether the parsed json_metadata is null before trying to read properties from it. The project uses lodash so
if (_.indexOf(postMetaData.app, 'steemit') === 0) {
canonicalHost = 'https://steemit.com';
}
could become
if (_.isNull(postMetaData) || _.indexOf(postMetaData.app, 'steemit') === 0) {
canonicalHost = 'https://steemit.com';
}
However there are many ways to fix this bug so the developers may choose a different solution.