anchor.diff:                       ?MODULE,
                        ?LINE,
                        {Reason, Name, Avp#diameter_avp.name, Mod, Stack}),
  -    rc(Reason, Avp, Opts, Mod).
  +    case Reason of
  +        {'DIAMETER', 5014 = RC, _} ->
  +            %% Length error communicated from diameter_types or a
  +            %% @custom_types/@codecs module.
  +            AvpName = Avp#diameter_avp.name,
  +            {RC, Avp#diameter_avp{data = Mod:empty_value(AvpName, Opts)}};
  +        _ ->
  +            {5004, Avp}
  +    end.
  +
  +%% 3588/6733:
  +%%
  +%%   DIAMETER_INVALID_AVP_VALUE         5004
  +%%      The request contained an AVP with an invalid value in its data
  +%%      portion.  A Diameter message indicating this error MUST include
  +%%      the offending AVPs within a Failed-AVP AVP.
   
   %% avp/6
   
  
positive.code: avp_arity(Name, AvpName, Mod, _, _) ->
      Mod:avp_arity(Name, AvpName).
  
  %% rc/4
  
  %% Length error communicated from diameter_types or a
  %% @custom_types/@codecs module.
  rc({'DIAMETER', 5014 = RC, _}, #diameter_avp{name = AvpName} = A, Opts, Mod) ->
      {RC, A#diameter_avp{data = Mod:empty_value(AvpName, Opts)}};
  
  %% 3588:
  %%
  %%   DIAMETER_INVALID_AVP_VALUE         5004
  %%      The request contained an AVP with an invalid value in its data
  %%      portion.  A Diameter message indicating this error MUST include
  %%      the offending AVPs within a Failed-AVP AVP.
  rc(_, Avp, _, _) ->
      {5004, Avp}.
  
  %% pack/5
  
  pack(Arity, F, Avp, Mod, [Failed | Rec]) ->
  
negative.code: 
  %% set/5
  
  set(_, _, _, _, Name)
    when is_atom(Name) ->
      Name;
  
  set(1, F, Value, _, Map)
    when is_map(Map) ->
  