DEV Community

Cover image for Today I found a bug !
Codeur Malin
Codeur Malin

Posted on

Today I found a bug !

Hello,

I like coding, I do that everyday but something strange happened to me today. I work in a company that use extern library with API for his business and I have for mission to update a block that use one of this services with extra data.

Humm.. ok no problem. I'm used to doing this kind of things.
I start to read in the documentation of this library to find out me how it works, and.. Ok I show it.

I'm ready to code, I go in my terminal create a new branch from preprod and let's go.
Time flies, I see things take shape I'm glad but when I test I don't get what I expected. Oooookay I should miss something, I go to the documentation recheck if I forget something but no all look good.

OK maybe there are a dependencies problem ? I check my composer.. Yeah maybe if I update this one it will works. Let's go for that !

A few minutes later

Still same errors grrr !

OK why you don't work *** !?
I don't have a great debugger to help me to find a solution but I saw all Rambo movies and I know what has to be done. I decide to put on a bandanna on my head and dump my request every place where he go to find where it goes wrong.

Go Rambo go !

I started by putting dump in 2 places, first at the end of my code to show if I send correct data (just to be sure because in theorie I have already test that)
And the other place is directly in the library i use for make connection with this service, juste before the request is sent correctly.

So the first dump I have put, looks ok the data look like it's demand.
And the second, looks good too.. Damnit !

OK I'm confused, I don't know why it doesn't work but there are a fact it's doesn't works. Code isn't magic there are necessarily somewhere a thing who's going bad.
Well, let's try something else. Humm.. I will simulate the call with Postman maybe I will show a new errors message that can help me ?
So I do that and.. It works !

Magic !

Wait.. what ?!
It works, but I do the same things.

To tell the truth at this moment I am nevertheless delighted to have a good result

Why in Postman it works but not when I execute my code ? I'm sure now my data are good so I check carefully every data send in the library are correct and.. voila I found It !!

I did not pay attention but the library convert boolean to integer and there goes the shit. It sounds futile but the typehint is very important.

So after discovery that bug, I went to the Github repository of that library and make a pull request with a little fix. Pending, I make a fork of this repository with the fix and use it directly in my project.

Today I found a bug and I tried to fix it !

And you have you already found a bug in a library ?

Thank for reading,
Codeur M

Top comments (0)