loading...
Cover image for Lessons from my First Open Source Contribution

Lessons from my First Open Source Contribution

andy profile image Andy Zhao (he/him) ・Updated on ・3 min read

When I graduated from my coding bootcamp, I had a lot of ideas of how to get a job and be the 'ideal candidate'. You've probably heard it all already:

  • "Contribute to open source projects!"
  • "Write technical blogs!"
  • "Study algorithms!"
  • "Don't study algorithms, you're wasting your time!"
  • "Learn [insert popular framework]; everyone is using it!"
  • "Network with devs/recruiters/companies!"
  • "Work on side projects you're passionate about!"

Now it's all good advice, but I ended up just studying and keeping to myself because I felt like I didn't have anything to contribute to others. "Who would read anything I write?" and "I can't add any value to Rails or Angular," were some of the thoughts that made me doubt myself.

On top of that, I became a teacher assistant at my coding bootcamp, giving me an excuse to be complacent and do less.

Patrick from Spongebob crossing off "Nothing" on a checklist

Clearly easier to do nothing.

Thankfully, being a TA exposes me to beginners who always have questions to ask, and one of those questions led me to my first open source contribution to the Ruby gem Faker - a library that generates fake data. And no, I wasn't just trying to add more Star Wars quotes; there was a different problem.

The Problem, and Supposed Solution

My student was trying to use a class in that gem that generates a link to an image of Bill Murray. However, when running the method with the default arguments, I got an argument error:

NoMethodError: undefined method `match' for 200:Fixnum

I looked into Faker's codebase, and checked out the method:

    def image(grayscale = false, width = 200, height = 200)
        raise ArgumentError, "Width should be a number" unless width.to_s.match(/^\d+$/)
        raise ArgumentError, "Height should be a number" unless height.to_s.match(/^\d+$/)
        raise ArgumentError, "Grayscale should be a boolean" unless [true, false].include?(grayscale)

        grayscale == true ? "https://fillmurray.com/g/#{width}/#{height}" : "https://fillmurray.com/#{width}/#{height}"
    end

Well, nothing looked wrong with the method to me, but neither my student's machine nor mine ran the code successfully. I checked to see if our versions matched the latest release, and it did. Perhaps the default arguments weren't being converted to strings with to_s, and therefore the match method was being called on 200 as a Fixnum.

So, I ended up forking it down, making some edits to seemingly fix it, ran the code in my console, and it worked! I followed the contributing guidelines, and made my first pull request.

The Real Solution

Disney Alice in Wonderland falling down the rabbit hole

Into the rabbit hole we went...

A few days later, I got a response. Someone had the same question, wondering why the code in the codebase didn't work. They asked me what my Ruby version I was running, and also if I could explain the bug. I got why he asked about my Ruby version, but I also didn't understand why the original code didn't work. I checked and updated my Ruby version, then ran the code. Got the same error. Hmm...

Then it hit me: maybe my local Faker files weren't correct. I spent a few minutes figuring how to locate them, and then I opened the file. Lo-and-behold, my local file's method didn't convert any arguments to strings!

But I had the latest release; why wasn't my code matching the code on GitHub? So, I searched the issues, and noticed that the date of the merged pull request was after the latest release. I closed my pull request, and finished my first open source contribution!

Now... what did I learn?

While it really wasn't much of a contribution, I'm glad I went down the wrong rabbit hole. I learned a lot more about contributing to open source than I would have if I simply noticed my local files were not up-to-date.

There were a bunch of technical details, too, but what was really important to me was that I started working again. When I wasn't doing anything, the momentum was against me: it was easier to do nothing than it was to do something. Now I'm writing technical posts again after feeling too shy about it a few months ago. The more I work, the more confident I feel to do more.

With all that, I hope you've enjoyed reading my post! I'll definitely be writing again. Until then, fellow devs.

Discussion

pic
Editor guide
Collapse
taggervng profile image
tag hatle

This was really encouraging, thanks for this! It's one thing to tell yourself that other people feel like this, but to see your experience of it is helpful and inspiring.

Collapse
andy profile image
Andy Zhao (he/him) Author

For sure! Happy to share my experience, especially if it's uplifting to others.

Collapse
jonbarcus profile image
Jonathan Barcus

Thanks for writing this!

Very encouraging for someone that can relate!

Collapse
andy profile image
Andy Zhao (he/him) Author

Thanks for reading!

Collapse
jmmccasland profile image
John Michael McCasland

Thanks for the great post, I've been in a similar boat the past few weeks! Its nice to hear someone sharing the same issues and working through it.

Collapse
andy profile image
Andy Zhao (he/him) Author

Glad you enjoyed it! +1 for community.

Collapse
andy profile image
Andy Zhao (he/him) Author

Definitely agree; it's hard to get started, but once I did I felt much better! Passion is what's going to drive us further :)