File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -440,9 +440,6 @@ int aws_mqtt_append_sdk_metrics_to_username(
440440 if (existing_content .len > 0 ) {
441441 s_parse_delimited_entries (existing_content , semicolon_delim , & metadata_param_list );
442442 }
443-
444- /* Remove existing Metadata from username_params_list - we'll merge and re-add */
445- aws_array_list_erase (& username_params_list , existing_metadata_index );
446443 } else {
447444 /* Wrong format: keep the original metadata value unchanged and don't append new metadata */
448445 AWS_LOGF_DEBUG (
@@ -471,12 +468,17 @@ int aws_mqtt_append_sdk_metrics_to_username(
471468 goto cleanup ;
472469 }
473470
474- /* Add Metadata parameter to username_params_list */
471+ /* Add or replace Metadata parameter in username_params_list */
475472 struct aws_uri_param metadata_params = {
476473 .key = metadata_str ,
477474 .value = aws_byte_cursor_from_buf (& metadata_value_buf ),
478475 };
479- aws_array_list_push_back (& username_params_list , & metadata_params );
476+ if (existing_metadata_param != NULL ) {
477+ /* Replace existing Metadata parameter at the same index */
478+ aws_array_list_set_at (& username_params_list , & metadata_params , existing_metadata_index );
479+ } else {
480+ aws_array_list_push_back (& username_params_list , & metadata_params );
481+ }
480482 }
481483 }
482484
You can’t perform that action at this time.
0 commit comments