Contributing to Telescope

When looking for an issue to work on in telescope I saw that there was a bug with the appearance of empty blog posts. I decided to investigate this issue and see what was causing it and so I start reading through telescope’s code. I was sure that the issue was on the backend but there were two ways of fixing the issue, either not rendering it on the frontend which is kind of a bad fix, or not considering it a valid post on the backend which is the route I went with.

I first looked into the package.json to see the scripts that start the backend to view where I should start reading, I started working from the beginning of the index.js file found in the src/backend folder until I came across the bull feed processor where posts are processed and I found that the issue ended up being blog posts with whitespace were considered valid as they do technically have text except it’s blank. Since the RSS feed post descriptions are raw HTML, I used the jsdom package to create an HTML fragment and retrieve its context which is the text found between the HTML tags.

When the context was retrieved, I decided to replace all whitespace with an empty character and then check its length to check if the description only had blank characters. If the description is blank it would now throw an error so that the post would not be added to our Redis instance. After the fix is made I wrote in the thread that I needed to find a way to test the fix and David (humphd) directed me to where the tests should be written, I never wrote jest tests before so I looked at the existing tests and copied their structure and changed the test to check my specific use case with a mock whitespace only HTML fragment I created.

After I ran the test and it passed, I pushed it to my fix branch and created a pull request. And then my CI builds failed. Turns out I forgot to run prettier, so I formatted my code and pushed it again. The CI builds failed once again. Now, I forgot to lint my code. Great. So, I lint my code with eslint and again, push my code. Finally, after wrestling with CI my code is formatted and linted, everyone is happy, and the builds now pass marking my PR complete. After my code was reviewed it was merged into master so now, we should no longer have empty blog posts appear.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: