@@ -553,18 +553,6 @@ mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
553553 cluster , cmd , compressor_id , reply , error );
554554 }
555555
556- if (_mongoc_cse_is_enabled (cluster -> client )) {
557- bson_destroy (& decrypted );
558- retval = _mongoc_cse_auto_decrypt (
559- cluster -> client , cmd -> db_name , reply , & decrypted , error );
560- bson_destroy (reply );
561- bson_steal (reply , & decrypted );
562- bson_init (& decrypted );
563- if (!retval ) {
564- goto fail_no_events ;
565- }
566- }
567-
568556 if (retval && callbacks -> succeeded ) {
569557 bson_t fake_reply = BSON_INITIALIZER ;
570558 /*
@@ -612,6 +600,18 @@ mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
612600 mongoc_apm_command_failed_cleanup (& failed_event );
613601 }
614602
603+ if (retval && _mongoc_cse_is_enabled (cluster -> client )) {
604+ bson_destroy (& decrypted );
605+ retval = _mongoc_cse_auto_decrypt (
606+ cluster -> client , cmd -> db_name , reply , & decrypted , error );
607+ bson_destroy (reply );
608+ bson_steal (reply , & decrypted );
609+ bson_init (& decrypted );
610+ if (!retval ) {
611+ goto fail_no_events ;
612+ }
613+ }
614+
615615 _handle_not_primary_error (cluster , server_stream , reply );
616616
617617 _handle_txn_error_labels (retval , error , cmd , reply );
0 commit comments