Can't you use DELETE_OPTION_IF_EXISTS(index_spec, "socketTimeoutMS") here?