On the face of it your solidity looks OK so I would guess that what’s happening is that either there’s something wrong with the function you’re using to call it or the data you expect to be there isn’t there because some previous step doesn’t work, or you’re passing the key in wrongly. We can’t tell because you didn’t post that function to stackexchange and we don’t know how you set the data up.
If you’re going to use the “debug by fiddling around with it” method you might want to try reading the function through a block explorer so that you can make sure the data you expect is there. However this is quite a painful way to develop; I’d suggest you write some unit tests, which will probably help you solve the problem on your own, but if it doesn’t you can point people to the failing test and it’ll be easier for them to tell you why it’s failing.