[fix] Fix app upgrade issue and handle errors in tools_upgrade