anchor.diff:                  Client,
                   Defaults).
   
  --spec set_name_values(ej:json_object(), binary() | undefined) -> {binary(), ej:json_object()} | no_return().
  -set_name_values(Client, ReqName) ->
  +set_name_values(Client) ->
       % Since either name or clientname is required (but not both), if only one is
       % passed, we will use it to set the other one
       Name = ej:get({<<"name">>}, Client),
       ClientName = ej:get({<<"clientname">>}, Client),
  -    % TODO: Can this be simplified?  Several of these cases are duplicates; doesn't
  -    % seem to be a case where reordering really solves the issue
  -    case {Name, ClientName, ReqName} of
  -        {undefined, undefined, _} ->
  +    case {Name, ClientName} of
  +        {Name, Name} ->
  +            Client;
  +        {Name, undefined} ->
  +            ej:set({<<"clientname">>}, Client, Name);
  +        {undefined, ClientName} ->
  +            ej:set({<<"name">>}, Client, ClientName);
  +        {_, _} ->
  +            throw({client_name_mismatch})
  +    end.
  +
  +validate_name_or_rename(Client, ReqName) ->
  +    Name = ej:get({<<"name">>}, Client),
  +    case {Name, ReqName} of
  +        {undefined, undefined} ->
               throw({both_missing, <<"name">>, <<"clientname">>});
  -        {Name, Name, undefined} ->
  -            {Name, Client};
  -        {Name, Name, Name} ->
  -            {Name, Client};
  -        {Name, Name, _} ->
  +        {undefined, _} ->
               {ReqName, ej:set({<<"name">>}, ej:set({<<"clientname">>},
                                                     Client, ReqName), ReqName)};
  -        {Name, undefined, undefined} ->
  -            {Name, ej:set({<<"clientname">>}, Client, Name)};
  -        {Name, undefined, Name} ->
  -            {Name, ej:set({<<"clientname">>}, Client, Name)};
  -        {Name, undefined, _} ->
  +        {Name, undefined} ->
  +            % This is a POST, nothing to do here
  +            {Name, Client};
  +        {Name, Name} ->
  +            % This is a regular PUT, nothing to do here
  +            {Name, Client};
  +        {Name, _} ->
  +            % This is a rename; we need to check for existing records
               {ReqName, ej:set({<<"name">>}, ej:set({<<"clientname">>},
  -                                                  Client, ReqName), ReqName)};
  -        {undefined, ClientName, undefined} ->
  -            {ClientName, ej:set({<<"name">>}, Client, ClientName)};
  -        {undefined, ClientName, ClientName} ->
  -            {ClientName, ej:set({<<"name">>}, Client, ClientName)};
  -        {undefined, ClientName, _} ->
  -            {ReqName, ej:set({<<"name">>}, ej:set({<<"clientname">>},
  -                                                  Client, ReqName), ReqName)};
  -        {_, _, _} ->
  -            throw({client_name_mismatch})
  +                                                  Client, ReqName), ReqName)}
       end.
   
   validate_client(Client, Name) ->
  
positive.code: %% @end
  parse_binary_json(Bin, ReqName, Defaults) ->
      Client = chef_json:decode_body(Bin),
      NewClient = case Defaults of
                      not_found ->
                          set_default_values(Client);
                      Values ->
                          set_default_values(Client, Values)
                  end,
      {Name, FinalClient} = set_name_values(NewClient, ReqName),
      valid_name(Name),
      validate_client(FinalClient, Name).
  
  client_spec(Name) ->
  
negative.code:         Bad -> throw(Bad)
      end.
  
  valid_name_format(Name) ->
      {Regex, Msg} = chef_regex:regex_for(client_name),
      case re:run(Name, Regex) of
          nomatch ->
  