Guarding against null in patchUserAgent