Can't get current entry's ID - Impossible to access an attribute ("id") on a null variable
Ok, so it came out that the post I used for testing wasn't assigned to any category and that was causing the exception. 

I added a validation for checking if the category is defined:

{{ (entry.blogCategory.one().id is defined and entry.blogCategory.one().id is not null) and entry.blogCategory.one().id == category.id ? 'light': 'primary' }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/li&gt;