Looking at the existing code I don't see any specific handling for checking the validity of the UUID in the error handling. And that should probably be done at an earlier stage. I think this problem should be tackled on the key_mgr side and not in the cinder/volume/api.py because this is related to key not present/invalid. Also since we do print the UUID it is easier to debug if it is the valid one although it might be better to add that check as well, but I think that can be another patch.
Looking at the existing code I don't see any specific handling for checking the validity of the UUID in the error handling. And that should probably be done at an earlier stage. I think this problem should be tackled on the key_mgr side and not in the cinder/ volume/ api.py because this is related to key not present/invalid. Also since we do print the UUID it is easier to debug if it is the valid one although it might be better to add that check as well, but I think that can be another patch.