User context missing when using toUrl in some circumstances