One of the pitfalls about being a Developer is you're eventually going to screw something up, and royally. It may not be today or tomorrow, but trust me when I say, it's inevitable.
I would even go as far as to say that the potential to create disastrous bug goes hand in hand with the amount of responsibility you have. You will create a bug that will surreptitiously seep through even the best unit tests, QA testing, and pull request reviews. It will leave you scratching your head and perhaps wondering why you didn't choose another line of work.
We all know that feeling you get in the pit of your stomach when you come to the stunning realization, "Oh bleep it was my fault!"
There's a couple of different ways to handle this sort of situation, and I'm going to explain those and why I think that taking full responsibility for your bug with dignity and grace is the best one.
First option: Try to pass the buck onto someone else.
In my opinion the worst option. I have been in a situation where I have spent hours going in circles with other Developers like some kind of horrible game of hot potato trying to pinpoint who created a bug. So much so that I wished it was me, so I could move on with my life. Not only is this a giant waste of time, but you're a Developer not a Detective. Eventually everything will fall into place, and you will wish you had those hours of your life back.
Try to correct the bug before anyone notices.
There are situations for example, like maybe you made a spelling error in your git commit message, and you want to correct it. That's a different story. If you are dealing with an issue that could have the potential to effect other Developers on your team, I would think twice before you do this. While fixing a bug quickly so that it goes under the radar is probably the most tempting option, sometimes this can come back to haunt you. Also making someone aware of a bug, helps your team document the process so that the same mistake doesn't happen again.
The jig is up!
A good manager and/or PM will understand that making boo-boos is unfortunately part of the job. It happens, and at the end of the day we're all human and we make mistakes. Don't be afraid to reach out and tell someone.
What you should be looking for to take away from this experience are these things:
- How was the bug created and why? Make sure you fully understand this so you can learn from it.
- What will you do in the future to avoid creating the same situation?
- Document it, so that members of your team can learn from your mistake.
I will say this, some of the craziest bugs I have created are some of the biggest opportunities to grow and learn. As Niels Bohr said, "An expert is a [wo]man who has made all the mistakes which can be made, in a narrow field."
So if you handle your bugs with dignity and grace and approach them as a learning tool rather than a total embarrassment to be avoided completely, you will end up with some valuable information. That way you will take away some great tools to add your back pocket which will help you avoid creating those pesky bugs in the first place.