Fix potential data loss if we try to fetch a non existing Ref after modifying the document

11 jobs for master in 11 minutes and 54 seconds (queued for 2 seconds)