Skip to content

Finding Bugs 🔎🐛

⚠️ WARNING

This mostly applies to finding small bugs and making minor enhcancements to the user interface.

Look at diffs on Bugzilla

Reading comments on bugs is a great way to understand more about the issue, but reading the diffs of the patches can give you an idea about how the problem was solved. Sometimes a bug that has been patched can inform you on how to approach your solution.

Take for example the recent major patch that protects Koha from CSRF attacks.

🐛 34478: Full CSRF protection
(blocker) Architecture, internals, and plumbing
Pushed to main

This patch caused many regressions throughout Koha where similar fixes needed to be applied. I happened to be using ktd testing a patch when the item search button that I was using stopped working. Someone on IRC pointed me to this bug which showed me how to fix the item search button.

🐛 36195: CSRF - testing reports
(critical) Architecture, internals, and plumbing
NEW

This OMNIBUS bug was created to track all the related bugs.

🐛 36192: [OMNIBUS] CSRF Protection for Koha
(critical) Architecture, internals, and plumbing
ASSIGNED

Use browser DevTools

🔧 TIP

non-clicky way

Press ctrl + shift + c to open up the DevTools Elements tab Hover the mouse over elements related to the bug your are looking for to highlight code in the DevTools panel

Look for something unique that you can search the codebase for. Generally an element's id is a good one, but if you can't find it easily keep in mind it's possible for these to be dynamically generated by the template.

Use the Console tab to test run code and look at data in the browser.

Use the Network tab to look at the request headers and for POST requests check the payload with the form data.

Use git grep

In the terminal or ktd inside the koha repo we can use git grep to search for a string in the codebase. You could also search in VSCode or in the GitHub or GitLab web interface, but git grep is less clicky and can git you superpowers if you learn a few tricks. Try searching for code related to your bug or code that has already solved a similar problem.

Use git blame

Once you find a place in the code where you want to learn more about use git blame to find the commit hash and then git show to find the bug number so you can look it up on Bugzilla and read the comments.

⌨️ TIP

non-clicky way
bash
git blame --color-by-age
git show {commit hash}

Try to walk through the code

For bugs that are mostly related to the user interface look at the Perl file from the url with extension .pl and its associated Template Toolkit file with extension .tt. Check the template for anything like [% INCLUDE 'somefile.inc' %] and open all the files. Try to get an idea of what parameters are being passed between the Perl file and the template and what is being done with them.