Forem PR Walkthroughs - MLH Fellowship 
Tags: opensource, forem, devbugsmash
Published: 2021-08-24 15:28:36

_Cover image by [Gabriel Valdez](https://unsplash.com/@gabrielvdz?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText%22%3E) on [Unsplash](https://unsplash.com/s/photos/roller-coaster?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText%22%3E)_

The end is near! One week remains of the 12 week long MLH Fellowship - the best learning experience of my life so far. Over the last 3 months, I had the amazing opportunity to contribute to [Forem](https://www.forem.com) - the very platform that DEV is built on. I thought about sharing my experience and work,  and what better platform to do it on than the one I contributed to. Here I present to you my beautiful Forem Adventures!

## My First PR

What does one do when they just begin contributing to a software? They look for good first issues of course! This issue seemed like it was the right fit!

{% github https://github.com/forem/forem/issues/13935 %} 

This issue reports a bug in how the markdown is processed in the comments, the strikethrough text wouldn't render correctly as per markdown rules - `~~text~~` within a link. I looked into the code base to find where the problem was. This was really challenging, I had underestimated how huge Forem is and took time understanding the code base. That is why you must always pick up an easy issue as your first one, it's more about understanding the code base than writing code. This issue helped me a lot to explore a lot of corners and understand the Forem architecture. I eventually found out that a method that shortened URLs in the comments was causing html tags to be stripped out. I fixed that and raised [PR 14103](https://github.com/forem/forem/pull/14103), my first PR to a huge repo, and my first bug fix.

**Except the bug wasn't solved**

Even after the PR got merged, it kept bugging me that my fix wouldn't resolve all edge cases, I tried it out in the production and indeed, I found more bugs. Which leads me to - 

## My First Issue

I raised an issue relating to the bug I found while working on the above PR. I found out that only the bug relating to strikethrough text was solved, but the comments were stripping out all sorts of text formatting, which leaves the user just plain text at disposal ;-; .

{% github https://github.com/forem/forem/issues/14114 %} 

Since I had already worked on it earlier and had an idea how to solve this, I worked on the fix for it and raised [PR 14240](https://github.com/forem/forem/pull/14240) . I tested it out, maintainers reviewed it, it got pushed to prod and I called it a day. 

**Except it wasn't solved yet**, which leads me to - 

## The bug I pushed to Prod

Yeah, this is embarrassing. Even though I thought I had thoroughly tested my code, both manually and automatically but I still had to try it out in Production, on DEV.to. I happened to come across a bug, which was produced due to the changes I made. Fortunately, I noticed it soon enough, and had the PR reverted - 

{% github https://github.com/forem/forem/pull/14240#issuecomment-881130782 %} 

Eventually, I had this fixed with [PR 14262](https://github.com/forem/forem/pull/14262). This time I was sure to test it thoroughly and finally closed the issue.

**If you were to comment anywhere on DEV now, you can use all sorts of formatting within links and it'll work its magic!**

## My Second Bug Fix  

Oh boy, this was a tough one. And my favorite one to work on. I present to you the RSS Feed Dilemma -

{% github https://github.com/forem/forem/issues/13185 %}

If you are unaware about RSS Feeds - they are xml files that summarize your webpages which lets you import your data to other webapps. They are a simple solution to achieve cross app communication. 

Forem uses this feature to allow users to import their blogs from other blogging websites like medium, and other forem instances as well. This works by setting your Source RSS Feed URL in Settings -> Extensions. 

It works fine when only one user is accessing a certain feed, but since RSS feeds are public, it is entirely possible for other users on a Forem instance to import blogs from the same feed as well. In this case, an article from the feed would get imported only to one of those users randomly, because of how Forem's post settings work. It made sense too, since multiple imports will lead to duplication. But there was no way to verify the true owner of the RSS feed, and no apparent way for the owner to know why some articles won't get imported. A fix was required, or just a way to let the users know what was going on. However, it was hard to decide what to do, whilst preserving content uniqueness.

I explained this issue to the maintainers, and together we decided that the best approach would be to allow duplicate draft posts, but only one of them be allowed to publish. If the  post has already been published, another user who tries to do the same will get a useful error message and be suggested to contact the core team. Content uniqueness preserved, users not ghosted anymore, everyone happy. I closed this issue with [PR 14160](https://github.com/forem/forem/pull/14160).

To learn more about the dilemma - 

{% github https://github.com/forem/forem/issues/13185#issuecomment-872681158 %}

I'll definitely be writing a more detailed post on this one, but before then I will find myself using the feeds import feature to import this post over to other Forems, hopefully someone doesn't beat me to it 👀.

## Other super cool stuff

I wish to write detailed walk-throughs for all my PRs at Forem in the hopes that other contributors might find something of use from my adventures. But until then here are some honorable mentions -

### Automatic Image Deletion 

Working on this issue made us discover a security issue that would arise by deleting images, and even though this could not get merged, I learned a lot about data storage by going through the code base. 

{% github https://github.com/forem/forem/pull/14141 %}

### Updating tags in articles on tag update

The issue was that if tag colors are updated by the admin, that change isn't reflected at other places because the colors are cached. I learned about how client side and server side caching works in Forem and was able to locate the bug. Easy peasy

{% github https://github.com/forem/forem/pull/14427 %}

### The Sponsors Image bug

{% github https://github.com/forem/forem/pull/14494 %}

### Refactoring and reorganizing code

I worked on a part of refactoring for StoriesController and **highly recommend** new contributors to try their hands on this issue. It's the best way to get familiarized with the code base and learn about what goes where and when a certain method is called.

{% github https://github.com/forem/forem/issues/2914 %}

## Takeaway

- I drastically increased my knowledge on system architecture and Rails practices by going through Forem's codebase.
- I learned about some amazing tools used in the codebase like zonebie, sidekiq, and RSS feeds that I am definitely going to try out in future projects.
- Before working on the RSS feed conflict and auto image deletion, I had previously never had to think about the social implications of certain changes in code, and it's amazing to have learned that.
- The whole experience definitely made me signficantly better at exploring large codebases to pin point bugs and make appropriate changes.   

## Shoutouts

- To @coffeecraftcode for helping me with all my troubles throughout the fellowship and the great conversations over maintainer meets.

- To @khattakdev 2.0 for being an amazing pod lead. Our Standups and 1-on-1s will be missed 🥺.

- To all the maintainers at Forem that closely reviewed my code and made sure I was giving my best. I learned a lot about the ins and outs of Rails and best coding practices through the reviews.