anchor.diff:        end).
   
   build_vbmap_chain(Chain, BucketUUID, IxToCouchDict, VBucket) ->
  -    do_build_vbmap_chain(Chain, BucketUUID, IxToCouchDict, VBucket, []).
  -
  -do_build_vbmap_chain([], _, _, _, R) ->
  -    {ok, lists:reverse(R)};
  -do_build_vbmap_chain([NodeIxRaw | Rest], BucketUUID, IxToCouchDict, VBucket, R) ->
  +    [NodeIxRaw | _Rest] = Chain,
       expect_number(
         NodeIxRaw, <<"Vbucket map chain">>,
         fun (NodeIx) ->
                 case NodeIx of
                     -1 ->
  -                      do_build_vbmap_chain(Rest, BucketUUID, IxToCouchDict,
  -                                           VBucket, [undefined | R]);
  +                      {ok, [undefined]};
                     _ ->
                         case dict:find(NodeIx, IxToCouchDict) of
                             error ->
  
positive.code:     with_server_list(
        ServerMap,
        fun (ServerList) ->
                case build_ix_to_couch_uri_dict(ServerList,
                                                McdToCouchDict) of
                    {ok, IxToCouchDict} ->
                        expect_nested_array(
                          <<"vBucketMap">>, ServerMap, <<"vbucket server map">>,
                          fun (VBucketMap) ->
                                  VBucketMapDict =
                                      build_vbmap(VBucketMap,
                                                  BucketUUID, IxToCouchDict),
  
                                  #remote_cluster{uuid=ClusterUUID} = RemoteCluster,
                                  RemoteBucket =
                                      #remote_bucket{uuid=BucketUUID,
                                                     cluster_uuid=ClusterUUID,
                                                     vbucket_map=VBucketMapDict},
  
                                  {ok, {RemoteCluster, RemoteBucket}}
                          end);
                    Error ->
                        Error
                end
        end).
  
  build_vbmap(RawVBucketMap, BucketUUID, IxToCouchDict) ->
  
negative.code:                                                   "vbucket map chain: ~p", [NodeIx]),
                                ?log_error("~s", [Msg]),
                                {error, bad_value, iolist_to_binary(Msg)};
                            {ok, none} ->
                                Msg = io_lib:format("Invalid node reference in "
                                                    "vbucket map chain: ~p. "
                                                    "Found node without couchApiBase in active vbucket map position", [NodeIx]),
                                ?log_error("~s", [Msg]),
                                {error, bad_value, iolist_to_binary(Msg)};
                            {ok, URL} ->
                                VBucketURL0 = [URL, "%2f", integer_to_list(VBucket),
                                               "%3b", BucketUUID],
                                VBucketURL = iolist_to_binary(VBucketURL0),
                                {ok, [VBucketURL]}
                        end
                end
        end).
  