Migration from QUIC_BUG to QUIC_BUG_V2(bug_id).

Per go/gfe-bug-improvements GFE_BUGs are getting stable IDs to allow for monitoring and alerting. Existing QUIC_BUG instances are changed to have `quic_bug_n_m` ID, where `n` is unique for each file, and `m` is a counter within each file, so we get `QUIC_BUG_V2(quic_bug_123_2)`

PiperOrigin-RevId: 361677239
Change-Id: I537fc53c4648a8b4a74ab8576b79b3c530bcb546
diff --git a/quic/core/quic_time_wait_list_manager.cc b/quic/core/quic_time_wait_list_manager.cc
index 641f5c9..d7ab999 100644
--- a/quic/core/quic_time_wait_list_manager.cc
+++ b/quic/core/quic_time_wait_list_manager.cc
@@ -224,7 +224,7 @@
   switch (connection_data->action) {
     case SEND_TERMINATION_PACKETS:
       if (connection_data->info.termination_packets.empty()) {
-        QUIC_BUG << "There are no termination packets.";
+        QUIC_BUG_V2(quic_bug_10608_1) << "There are no termination packets.";
         return;
       }
       switch (header_format) {
@@ -258,7 +258,7 @@
 
     case SEND_CONNECTION_CLOSE_PACKETS:
       if (connection_data->info.termination_packets.empty()) {
-        QUIC_BUG << "There are no termination packets.";
+        QUIC_BUG_V2(quic_bug_10608_2) << "There are no termination packets.";
         return;
       }
       for (const auto& packet : connection_data->info.termination_packets) {
diff --git a/quic/core/quic_trace_visitor.cc b/quic/core/quic_trace_visitor.cc
index 381d29b..cd5ea7f 100644
--- a/quic/core/quic_trace_visitor.cc
+++ b/quic/core/quic_trace_visitor.cc
@@ -22,7 +22,7 @@
     case ENCRYPTION_FORWARD_SECURE:
       return quic_trace::ENCRYPTION_1RTT;
     case NUM_ENCRYPTION_LEVELS:
-      QUIC_BUG << "Invalid encryption level specified";
+      QUIC_BUG_V2(quic_bug_10284_1) << "Invalid encryption level specified";
       return quic_trace::ENCRYPTION_UNKNOWN;
   }
 }
@@ -100,7 +100,7 @@
         break;
 
       case NUM_FRAME_TYPES:
-        QUIC_BUG << "Unknown frame type encountered";
+        QUIC_BUG_V2(quic_bug_10284_2) << "Unknown frame type encountered";
         break;
     }
   }
@@ -228,7 +228,7 @@
       break;
 
     case NUM_FRAME_TYPES:
-      QUIC_BUG << "Unknown frame type encountered";
+      QUIC_BUG_V2(quic_bug_10284_3) << "Unknown frame type encountered";
       break;
   }
 }
@@ -314,7 +314,8 @@
 uint64_t QuicTraceVisitor::ConvertTimestampToRecordedFormat(
     QuicTime timestamp) {
   if (timestamp < start_time_) {
-    QUIC_BUG << "Timestamp went back in time while recording a trace";
+    QUIC_BUG_V2(quic_bug_10284_4)
+        << "Timestamp went back in time while recording a trace";
     return 0;
   }
 
diff --git a/quic/core/quic_udp_socket_posix.cc b/quic/core/quic_udp_socket_posix.cc
index e410635..fbb7ebf 100644
--- a/quic/core/quic_udp_socket_posix.cc
+++ b/quic/core/quic_udp_socket_posix.cc
@@ -157,7 +157,8 @@
       if (self_v6_ip.FromPackedString(addr_data, addr_len)) {
         packet_info->SetSelfV6Ip(self_v6_ip);
       } else {
-        QUIC_BUG << "QuicIpAddress::FromPackedString failed";
+        QUIC_BUG_V2(quic_bug_10751_1)
+            << "QuicIpAddress::FromPackedString failed";
       }
     }
     return;
@@ -172,7 +173,8 @@
       if (self_v4_ip.FromPackedString(addr_data, addr_len)) {
         packet_info->SetSelfV4Ip(self_v4_ip);
       } else {
-        QUIC_BUG << "QuicIpAddress::FromPackedString failed";
+        QUIC_BUG_V2(quic_bug_10751_2)
+            << "QuicIpAddress::FromPackedString failed";
       }
     }
     return;
@@ -421,7 +423,8 @@
   }
 
   if (QUIC_PREDICT_FALSE(hdr.msg_flags & MSG_CTRUNC)) {
-    QUIC_BUG << "Control buffer too small. size:" << control_buffer.buffer_len;
+    QUIC_BUG_V2(quic_bug_10751_3)
+        << "Control buffer too small. size:" << control_buffer.buffer_len;
     return;
   }
 
@@ -509,9 +512,9 @@
 
     msghdr& hdr = hdrs[i].msg_hdr;
     if (QUIC_PREDICT_FALSE(hdr.msg_flags & MSG_CTRUNC)) {
-      QUIC_BUG << "Control buffer too small. size:"
-               << (*results)[i].control_buffer.buffer_len
-               << ", need:" << hdr.msg_controllen;
+      QUIC_BUG_V2(quic_bug_10751_4) << "Control buffer too small. size:"
+                                    << (*results)[i].control_buffer.buffer_len
+                                    << ", need:" << hdr.msg_controllen;
       continue;
     }
 
diff --git a/quic/core/quic_unacked_packet_map.cc b/quic/core/quic_unacked_packet_map.cc
index eeda215..be355ba 100644
--- a/quic/core/quic_unacked_packet_map.cc
+++ b/quic/core/quic_unacked_packet_map.cc
@@ -102,10 +102,10 @@
     case ACK_FREQUENCY_FRAME:
       return kAckFrequencyFrameBitfield;
     case NUM_FRAME_TYPES:
-      QUIC_BUG << "Unexpected frame type";
+      QUIC_BUG_V2(quic_bug_10518_1) << "Unexpected frame type";
       return kInvalidFrameBitfield;
   }
-  QUIC_BUG << "Unexpected frame type";
+  QUIC_BUG_V2(quic_bug_10518_2) << "Unexpected frame type";
   return kInvalidFrameBitfield;
 }
 
@@ -298,11 +298,12 @@
         GetPacketNumberSpace(info->encryption_level);
     if (bytes_in_flight_per_packet_number_space_[packet_number_space] <
         info->bytes_sent) {
-      QUIC_BUG << "bytes_in_flight: "
-               << bytes_in_flight_per_packet_number_space_[packet_number_space]
-               << " is smaller than bytes_sent: " << info->bytes_sent
-               << " for packet number space: "
-               << PacketNumberSpaceToString(packet_number_space);
+      QUIC_BUG_V2(quic_bug_10518_3)
+          << "bytes_in_flight: "
+          << bytes_in_flight_per_packet_number_space_[packet_number_space]
+          << " is smaller than bytes_sent: " << info->bytes_sent
+          << " for packet number space: "
+          << PacketNumberSpaceToString(packet_number_space);
       bytes_in_flight_per_packet_number_space_[packet_number_space] = 0;
     } else {
       bytes_in_flight_per_packet_number_space_[packet_number_space] -=
@@ -560,7 +561,8 @@
 QuicPacketNumber QuicUnackedPacketMap::GetLargestAckedOfPacketNumberSpace(
     PacketNumberSpace packet_number_space) const {
   if (packet_number_space >= NUM_PACKET_NUMBER_SPACES) {
-    QUIC_BUG << "Invalid packet number space: " << packet_number_space;
+    QUIC_BUG_V2(quic_bug_10518_4)
+        << "Invalid packet number space: " << packet_number_space;
     return QuicPacketNumber();
   }
   return largest_acked_packets_[packet_number_space];
@@ -569,7 +571,8 @@
 QuicTime QuicUnackedPacketMap::GetLastInFlightPacketSentTime(
     PacketNumberSpace packet_number_space) const {
   if (packet_number_space >= NUM_PACKET_NUMBER_SPACES) {
-    QUIC_BUG << "Invalid packet number space: " << packet_number_space;
+    QUIC_BUG_V2(quic_bug_10518_5)
+        << "Invalid packet number space: " << packet_number_space;
     return QuicTime::Zero();
   }
   return last_inflight_packets_sent_time_[packet_number_space];
@@ -579,7 +582,8 @@
 QuicUnackedPacketMap::GetLargestSentRetransmittableOfPacketNumberSpace(
     PacketNumberSpace packet_number_space) const {
   if (packet_number_space >= NUM_PACKET_NUMBER_SPACES) {
-    QUIC_BUG << "Invalid packet number space: " << packet_number_space;
+    QUIC_BUG_V2(quic_bug_10518_6)
+        << "Invalid packet number space: " << packet_number_space;
     return QuicPacketNumber();
   }
   return largest_sent_retransmittable_packets_[packet_number_space];
@@ -613,12 +617,14 @@
 
 void QuicUnackedPacketMap::EnableMultiplePacketNumberSpacesSupport() {
   if (supports_multiple_packet_number_spaces_) {
-    QUIC_BUG << "Multiple packet number spaces has already been enabled";
+    QUIC_BUG_V2(quic_bug_10518_7)
+        << "Multiple packet number spaces has already been enabled";
     return;
   }
   if (largest_sent_packet_.IsInitialized()) {
-    QUIC_BUG << "Try to enable multiple packet number spaces support after any "
-                "packet has been sent.";
+    QUIC_BUG_V2(quic_bug_10518_8)
+        << "Try to enable multiple packet number spaces support after any "
+           "packet has been sent.";
     return;
   }
 
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index 7eff759..79cf453 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -280,7 +280,8 @@
     src = static_cast<char*>(iov[iovnum].iov_base);
     copy_len = std::min(buffer_length, iov[iovnum].iov_len);
   }
-  QUIC_BUG_IF(buffer_length > 0) << "Failed to copy entire length to buffer.";
+  QUIC_BUG_IF_V2(quic_bug_10839_1, buffer_length > 0)
+      << "Failed to copy entire length to buffer.";
 }
 
 // static
@@ -356,7 +357,8 @@
     case ALL_INITIAL_RETRANSMISSION:
       return UNACKABLE;
     default:
-      QUIC_BUG << retransmission_type << " is not a retransmission_type";
+      QUIC_BUG_V2(quic_bug_10839_2)
+          << retransmission_type << " is not a retransmission_type";
       return UNACKABLE;
   }
 }
@@ -648,8 +650,9 @@
     case ENCRYPTION_FORWARD_SECURE:
       return APPLICATION_DATA;
     default:
-      QUIC_BUG << "Try to get packet number space of encryption level: "
-               << encryption_level;
+      QUIC_BUG_V2(quic_bug_10839_3)
+          << "Try to get packet number space of encryption level: "
+          << encryption_level;
       return NUM_PACKET_NUMBER_SPACES;
   }
 }
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 081791d..b125aac 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -59,8 +59,8 @@
   } else if (version == ParsedQuicVersion::Q043()) {
     SetQuicReloadableFlag(quic_disable_version_q043, disable);
   } else {
-    QUIC_BUG << "Cannot " << (enable ? "en" : "dis") << "able version "
-             << version;
+    QUIC_BUG_V2(quic_bug_10589_1)
+        << "Cannot " << (enable ? "en" : "dis") << "able version " << version;
   }
 }
 
@@ -232,9 +232,10 @@
   } else if (parsed_version == ParsedQuicVersion::ReservedForNegotiation()) {
     return CreateRandomVersionLabelForNegotiation();
   }
-  QUIC_BUG << "Unsupported version "
-           << QuicVersionToString(parsed_version.transport_version) << " "
-           << HandshakeProtocolToString(parsed_version.handshake_protocol);
+  QUIC_BUG_V2(quic_bug_10589_2)
+      << "Unsupported version "
+      << QuicVersionToString(parsed_version.transport_version) << " "
+      << HandshakeProtocolToString(parsed_version.handshake_protocol);
   return 0;
 }
 
@@ -255,7 +256,8 @@
       versions.push_back(version);
     }
   }
-  QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+  QUIC_BUG_IF_V2(quic_bug_10589_3, versions.empty())
+      << "No version with QUIC crypto found.";
   return versions;
 }
 
@@ -266,7 +268,8 @@
       versions.push_back(version);
     }
   }
-  QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+  QUIC_BUG_IF_V2(quic_bug_10589_4, versions.empty())
+      << "No version with QUIC crypto found.";
   return versions;
 }
 
@@ -277,7 +280,8 @@
       versions.push_back(version);
     }
   }
-  QUIC_BUG_IF(versions.empty()) << "No version with TLS handshake found.";
+  QUIC_BUG_IF_V2(quic_bug_10589_5, versions.empty())
+      << "No version with TLS handshake found.";
   return versions;
 }
 
@@ -288,7 +292,8 @@
       versions.push_back(version);
     }
   }
-  QUIC_BUG_IF(versions.empty()) << "No version with TLS handshake found.";
+  QUIC_BUG_IF_V2(quic_bug_10589_6, versions.empty())
+      << "No version with TLS handshake found.";
   return versions;
 }
 
@@ -414,7 +419,8 @@
         filtered_versions.push_back(version);
       }
     } else {
-      QUIC_BUG << "QUIC version " << version << " has no flag protection";
+      QUIC_BUG_V2(quic_bug_10589_7)
+          << "QUIC version " << version << " has no flag protection";
       filtered_versions.push_back(version);
     }
   }
diff --git a/quic/core/tls_chlo_extractor.cc b/quic/core/tls_chlo_extractor.cc
index ca9eb5b..d11b95c 100644
--- a/quic/core/tls_chlo_extractor.cc
+++ b/quic/core/tls_chlo_extractor.cc
@@ -129,8 +129,8 @@
 bool TlsChloExtractor::OnProtocolVersionMismatch(ParsedQuicVersion version) {
   // This should never be called because we already check versions in
   // IngestPacket.
-  QUIC_BUG << "Unexpected version mismatch, expected " << framer_->version()
-           << ", got " << version;
+  QUIC_BUG_V2(quic_bug_10855_1) << "Unexpected version mismatch, expected "
+                                << framer_->version() << ", got " << version;
   return false;
 }
 
@@ -156,7 +156,7 @@
   if (frame.level != ENCRYPTION_INITIAL) {
     // Since we drop non-INITIAL packets in OnUnauthenticatedPublicHeader,
     // we should never receive any CRYPTO frames at other encryption levels.
-    QUIC_BUG << "Parsed bad-level CRYPTO frame " << frame;
+    QUIC_BUG_V2(quic_bug_10855_2) << "Parsed bad-level CRYPTO frame " << frame;
     return false;
   }
   // parsed_crypto_frame_in_this_packet_ is checked in IngestPacket to allow
@@ -242,7 +242,7 @@
     const std::string& callback_name) {
   std::string error_details =
       absl::StrCat("Unexpected callback ", callback_name);
-  QUIC_BUG << error_details;
+  QUIC_BUG_V2(quic_bug_10855_3) << error_details;
   HandleUnrecoverableError(error_details);
 }
 
@@ -311,8 +311,8 @@
   } else if (state_ == State::kParsedPartialChloFragment) {
     state_ = State::kParsedFullMultiPacketChlo;
   } else {
-    QUIC_BUG << "Unexpected state on successful parse "
-             << StateToString(state_);
+    QUIC_BUG_V2(quic_bug_10855_4)
+        << "Unexpected state on successful parse " << StateToString(state_);
   }
 }
 
diff --git a/quic/core/tls_client_handshaker.cc b/quic/core/tls_client_handshaker.cc
index 7163bd5..84f9602 100644
--- a/quic/core/tls_client_handshaker.cc
+++ b/quic/core/tls_client_handshaker.cc
@@ -58,7 +58,7 @@
     // TODO(b/154162689) add PSK support to QUIC+TLS.
     std::string error_details =
         "QUIC client pre-shared keys not yet supported with TLS";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10576_1) << error_details;
     CloseConnection(QUIC_HANDSHAKE_FAILED, error_details);
     return false;
   }
@@ -116,7 +116,8 @@
       handshaker_delegate()->ProcessTransportParameters(
           *(cached_state->transport_params),
           /*is_resumption = */ true, &error_details) != QUIC_NO_ERROR) {
-    QUIC_BUG << "Unable to parse cached transport parameters.";
+    QUIC_BUG_V2(quic_bug_10576_2)
+        << "Unable to parse cached transport parameters.";
     CloseConnection(QUIC_HANDSHAKE_FAILED,
                     "Client failed to parse cached Transport Parameters.");
     return false;
@@ -130,7 +131,8 @@
     if (!cached_state->application_state ||
         !session()->ResumeApplicationState(
             cached_state->application_state.get())) {
-      QUIC_BUG << "Unable to parse cached application state.";
+      QUIC_BUG_V2(quic_bug_10576_3)
+          << "Unable to parse cached application state.";
       CloseConnection(QUIC_HANDSHAKE_FAILED,
                       "Client failed to parse cached application state.");
       return false;
@@ -150,11 +152,11 @@
       return true;
     }
 
-    QUIC_BUG << "ALPN missing";
+    QUIC_BUG_V2(quic_bug_10576_4) << "ALPN missing";
     return false;
   }
   if (!std::all_of(alpns.begin(), alpns.end(), IsValidAlpn)) {
-    QUIC_BUG << "ALPN too long";
+    QUIC_BUG_V2(quic_bug_10576_5) << "ALPN too long";
     return false;
   }
 
@@ -170,9 +172,10 @@
   success =
       success && (SSL_set_alpn_protos(ssl(), alpn, alpn_writer.length()) == 0);
   if (!success) {
-    QUIC_BUG << "Failed to set ALPN: "
-             << quiche::QuicheTextUtils::HexDump(absl::string_view(
-                    alpn_writer.data(), alpn_writer.length()));
+    QUIC_BUG_V2(quic_bug_10576_6)
+        << "Failed to set ALPN: "
+        << quiche::QuicheTextUtils::HexDump(
+               absl::string_view(alpn_writer.data(), alpn_writer.length()));
     return false;
   }
 
@@ -186,7 +189,7 @@
       if (SSL_add_application_settings(
               ssl(), reinterpret_cast<const uint8_t*>(alpn_string.data()),
               alpn_string.size(), nullptr, /* settings_len = */ 0) != 1) {
-        QUIC_BUG << "Failed to enable ALPS.";
+        QUIC_BUG_V2(quic_bug_10576_7) << "Failed to enable ALPS.";
         return false;
       }
     }
@@ -551,7 +554,7 @@
 
 void TlsClientHandshaker::InsertSession(bssl::UniquePtr<SSL_SESSION> session) {
   if (!received_transport_params_) {
-    QUIC_BUG << "Transport parameters isn't received";
+    QUIC_BUG_V2(quic_bug_10576_8) << "Transport parameters isn't received";
     return;
   }
   if (session_cache_ == nullptr) {
diff --git a/quic/core/tls_handshaker.cc b/quic/core/tls_handshaker.cc
index 133c85c..b76fbcc 100644
--- a/quic/core/tls_handshaker.cc
+++ b/quic/core/tls_handshaker.cc
@@ -251,7 +251,7 @@
       one_rtt_read_header_protection_key_.empty() ||
       one_rtt_write_header_protection_key_.empty()) {
     std::string error_details = "1-RTT secret(s) not set yet.";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10312_1) << error_details;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details);
     return nullptr;
   }
@@ -276,7 +276,7 @@
   if (latest_write_secret_.empty() ||
       one_rtt_write_header_protection_key_.empty()) {
     std::string error_details = "1-RTT write secret not set yet.";
-    QUIC_BUG << error_details;
+    QUIC_BUG_V2(quic_bug_10312_2) << error_details;
     CloseConnection(QUIC_INTERNAL_ERROR, error_details);
     return nullptr;
   }
diff --git a/quic/core/tls_server_handshaker.cc b/quic/core/tls_server_handshaker.cc
index c12caa5..83fdf35 100644
--- a/quic/core/tls_server_handshaker.cc
+++ b/quic/core/tls_server_handshaker.cc
@@ -55,7 +55,8 @@
     const std::vector<uint8_t>& /*quic_transport_params*/,
     const absl::optional<std::vector<uint8_t>>& /*early_data_context*/) {
   if (!handshaker_ || !proof_source_) {
-    QUIC_BUG << "SelectCertificate called on a detached handle";
+    QUIC_BUG_V2(quic_bug_10341_1)
+        << "SelectCertificate called on a detached handle";
     return QUIC_FAILURE;
   }
 
@@ -81,12 +82,13 @@
     absl::string_view in,
     size_t max_signature_size) {
   if (!handshaker_ || !proof_source_) {
-    QUIC_BUG << "ComputeSignature called on a detached handle";
+    QUIC_BUG_V2(quic_bug_10341_2)
+        << "ComputeSignature called on a detached handle";
     return QUIC_FAILURE;
   }
 
   if (signature_callback_) {
-    QUIC_BUG << "ComputeSignature called while pending";
+    QUIC_BUG_V2(quic_bug_10341_3) << "ComputeSignature called while pending";
     return QUIC_FAILURE;
   }
 
@@ -489,7 +491,8 @@
     std::vector<uint8_t> early_data_context;
     if (!SerializeTransportParametersForTicket(
             server_params, *application_state_, &early_data_context)) {
-      QUIC_BUG << "Failed to serialize Transport Parameters for ticket.";
+      QUIC_BUG_V2(quic_bug_10341_4)
+          << "Failed to serialize Transport Parameters for ticket.";
       result.early_data_context = std::vector<uint8_t>();
       return result;
     }
@@ -570,7 +573,8 @@
     std::unique_ptr<ProofVerifyDetails>* /*details*/,
     uint8_t* /*out_alert*/,
     std::unique_ptr<ProofVerifierCallback> /*callback*/) {
-  QUIC_BUG << "Client certificates are not yet supported on the server";
+  QUIC_BUG_V2(quic_bug_10341_5)
+      << "Client certificates are not yet supported on the server";
   return QUIC_FAILURE;
 }
 
@@ -743,7 +747,8 @@
 
   if (!pre_shared_key_.empty()) {
     // TODO(b/154162689) add PSK support to QUIC+TLS.
-    QUIC_BUG << "QUIC server pre-shared keys not yet supported with TLS";
+    QUIC_BUG_V2(quic_bug_10341_6)
+        << "QUIC server pre-shared keys not yet supported with TLS";
     return ssl_select_cert_error;
   }