I had this problem when I was writing an initializer script for one of the custom fields in my JIRA instance.
Found a piece that isn’t well documented. But as usual, I’m explaining my steps and then the solution. It’s no real big deal anyway. 🙂
Edit (24 May): Spoiler alert! There’s a better way.
I came across a corrupted JIRA database with all projects lost their permission schemes.