retry logic: handle empty/malformed responses from API server