fix get api key bug

if a stage is not in db, the api key will bi nil.