Problems with HTTP interceptors for browser redirects

At work I was debugging an issue that was coming from one of the Vuejs components and it was registered on Airbrake. The error indicated that a value we expect to have in one of the Vuex storages was not there. Architecture wise we have an initial boot process that run on page load and add the values to the storage. If this succeeds, then we create the main Vuejs app component to have a reactive web app....

January 26, 2021 · Sinaru Gunawardena

To use 404 code or not

At work I’m working on implementing REST based API end-points to expand the functionaity of the front-end application. Recently I had a discussion with one of the developers in the team about what HTTP error should be used when something that is expected to be present is missing due to some inconsistency in the server. Suppose you have a resource type called File Resource. Let’s assume that we have two endpoints for this:...

January 23, 2021 · Sinaru Gunawardena

Things to consider when upgrading Rails

Recently at work I had the opportunity to upgrade Rails from 4.2 all the way to Rails 6.1 for one of the core applications. With the experience, In this article I’m discussing some important points to consider when you are upgrading Rails. ...

January 2, 2021 · Sinaru Gunawardena

Updating Rails app gems

Past few weeks, we have been focusing on updating Gems of our Rails application. ...

September 4, 2019 · Sinaru Gunawardena

Sometimes you have to look back when debugging

Last week has been a firefighting week at work (i.e. debugging and troubleshooting). I’m writing this article to share my experience with debugging a system configuration at work. In the end of article, I have placed some lessons learned points so hopefully someone can learn from it to improve their career. ...

September 15, 2018 · Sinaru Gunawardena

Trailing whitespaces: what you gonna do about it?

What is a trailing whitespace? Trailing whitespace is any spaces or tabs after the last non-whitespace character on the line until the newline. Background Few months ago, it was raised that PR submitted code tend to have trailing whitespace changes in code diff along with other “real” code changes. This whitespace change is a diff where the change was removing one or more trailing whitespaces from the existing code. We then noticed that the editors we were using were automatically removing trailing whitespaces that were already existed in the code when the file get saved....

January 9, 2017 · Sinaru Gunawardena

Having a newline character at end of file

Background/problem/question: When you create a newfile, and push it to Github, in code diff view, it will say no newline at end of file. Sometimes text editors would also add an EOF newline, if they noticed that the file being edited does not end in a newline, when they are saved (usually it is configured that way by default). Reasoning: In POSIX, a line is a sequence of zero or more non-newline characters plus a terminating character....

January 9, 2017 · Sinaru Gunawardena

Use different conditions to test methods

Let’s say that you have a function that takes an HTML structure and check items. For simplicity, our method would check if each item in the list has a link pointing to type of resource (A). So here can write a test that takes a list with items containing resource A links. Here we expect the function to return true. But this does not guarantee that the function is working as there is another outcome from the function which false....

October 15, 2016 · Sinaru Gunawardena

Don’t commit the first thing that works

I was working on a bug fix on our application with another fellow programmer. First we understood the root cause of the bug and what makes it to happen. All that was good. Then we thought of a solution and applied the first fix that I thought. Code works and bug is fixed, happy days. But wait. Then I thought about the fix and it’s complexity. The bug was causing due to a list that is not getting updated and it was referring to an old memorized list that we lose track once the list is created....

October 9, 2016 · Sinaru Gunawardena

Personal note on how a bug is tracked and fixed at work

Story Today was a good day at work. There was a spike card was mentioning about a bug that was occurring at random actions. However the QAs have found that behavior to be specific for a section of the application. Given the spike card work to track down the cause of this bug was set to 1 day, we manage to find the cause and also fix it with precise thought and action nearly under a 1 day....

August 16, 2016 · Sinaru Gunawardena