Added improved error handling for malformed avatar uploads