This is my final post of my contribution series and in this blog I will be talking about how I was able to complete my contribution(well kind of).
Context
So as a part of my course, I was supposed to make an impactful contribution to any repo that we like. I worked on this issue and this is my PR. Notice how both of these are in different repo. Yeah I was surprised too, I took this issue because I kind of understood what was happening in the original repo, but the other repo had me stressing because how hard it was me to understand. Check out my Blog1 and Blog2 to get an idea where we are at.
The PR
I raised my first PR in my last blog, after some days I got two reviews. One was to not throw anything in the deepest part of the function because its being used by a lot of other flows and we dont want to disturb them because that is not in the scope of the issue. and the other one was to use the mutation module that they had in the repository to throw so that the throws are consistent. Working with this module was very neat and made my code look better. Made me realize that one aspect of open source contribution is to make sure that in our first walk around the repository, we are looking at certain things are done that we might have to implement. For example I knew that I had to throw which was for sure because it was what the story was about, instead I used up a lot time just understanding how the code works and not how the throwing syntax look like. I fixed those changes and pushed my new changes for them to got reviewed.
The changes got approved this time, and there was a suggestion to add tests, I had some time left before the deadline of this project, So I thought why not?. This was not as straightforward as I thought it will be. Before I start adding my tests, I wanted to run other tests. However, The tests were just not running for some reason and on top of that there was no logs for me to debug, until I figured out that it had its own local package.json file which was new for new. Anyways I downloaded the dependancies and ran the tests again. And guess what? it failed again. Fortunately this time, there were some logs. I looked at the logs and found out that the tests were trying to hit a port, was I supposed to run the server before tests? I had a lot of questions which made me wander for a readme file or something. While looking for a readme, I found a dockerfile and had an ahha moment. This was it!!. I had to run a docker file before the tests and after that all of the tests were starting. Adding the test was the easy part because I was already a little familiar with the code. I have pushed the tests with a screenshot of it passing.
My changes in detail
So there was this route which was returning 500 when a database for a user was not existing. The story wanted me to do 404 if the user does not exist and 410 if the user deleted their account recently. the latter got me scratching my head. I looked at the logs in the screenshot of the issue and traced the files where this 500 could be returned. I changed this too 404 (which I ended up reverting because this was being used by a lot of other flows and we dont want to change that remember?). And I traced back a little bit and found the entry point of the route. I just added a small check there to retrieve the account using the WebID passed in the params. I used to ctx to run a function that gave me the account, I returned 404 if the account was not there and 410 if it had a deletedAt property. I found out that the delete function added this row to deleted accounts. So I just leveraged this row.
When I wanted to hit this route, the postman was just not working it was giving me a very cryptic error. After trying for a little bit, I had to consult with the other developers and they asked me comment out a check which fixed my issue. I knew that this check was the issue, but was unsure if this could be removed for debugging. The resulting code block might be short, but trust me this was defiantly one of the hardest project for me to work on, on par with the big repos I worked on at my coop.
The journey
Honestly, this was the hardest repo that I had to onboard myself onto. There was no typescript and a ctx was being passed everywhere. It took me so much time just to wrap my head around this idea of this architecture using ctx. Another hurdle was the fact that the code was split onto two different repos, so I had to link the code before I run the server. Booting the server was pretty straightforward because of the clear documentation, but coding was a little challenging. Every time I test my route using postman, I had to look at the logs in the first repo, but to find where the logs came from and debug further, I had to move to a different repo. Not a big deal breaker but inconvenient for sure. I was added to a matrix server and every one there were super welcoming and helpful and answered a couple of questions that I asked. I enjoyed working on this repo and learned a thing or two about the context architecture. Thank you for reading.
Top comments (0)