Defending against undefined and null attributes