Fix nil pointer error on upstrean error