Remove exception-throwing logic from QUICHE.

The current code is not exception-safe, and can be written more
efficiently in most cases.

Both {optional,StatusOr}::value and .at() perform bounds-checking
and will throw an exception (resulting in a SIGABRT and likely
process death for google3 binaries built with -fno-exceptions).

There are a few directories which are not included in this CL
(quic/moqt, quic/tools quiche/oblivious_http), as well as test-only
code.

PiperOrigin-RevId: 572643937
diff --git a/quiche/balsa/balsa_headers.h b/quiche/balsa/balsa_headers.h
index d0a4b6f..3e1823b 100644
--- a/quiche/balsa/balsa_headers.h
+++ b/quiche/balsa/balsa_headers.h
@@ -1260,7 +1260,7 @@
                          absl::string_view(stream_begin + line.value_begin_idx,
                                            line.ValuesLength()));
     }
-    return value_.value();
+    return *value_;
   }
 
   const BalsaHeaders* headers_;
diff --git a/quiche/http2/adapter/header_validator.cc b/quiche/http2/adapter/header_validator.cc
index d5e8ea3..690aa88 100644
--- a/quiche/http2/adapter/header_validator.cc
+++ b/quiche/http2/adapter/header_validator.cc
@@ -114,9 +114,9 @@
     return HEADER_FIELD_INVALID;
   }
   if (max_field_size_.has_value() &&
-      key.size() + value.size() > max_field_size_.value()) {
+      key.size() + value.size() > *max_field_size_) {
     QUICHE_VLOG(2) << "Header field size is " << key.size() + value.size()
-                   << ", exceeds max size of " << max_field_size_.value();
+                   << ", exceeds max size of " << *max_field_size_;
     return HEADER_FIELD_TOO_LONG;
   }
   if (key[0] == ':') {
@@ -289,8 +289,8 @@
   }
 
   if (content_length_.has_value()) {
-    return content_length == content_length_.value() ? CONTENT_LENGTH_SKIP
-                                                     : CONTENT_LENGTH_ERROR;
+    return content_length == *content_length_ ? CONTENT_LENGTH_SKIP
+                                              : CONTENT_LENGTH_ERROR;
   }
   content_length_ = content_length;
   return CONTENT_LENGTH_OK;
diff --git a/quiche/http2/adapter/oghttp2_session.cc b/quiche/http2/adapter/oghttp2_session.cc
index a2f4605..fdf308e 100644
--- a/quiche/http2/adapter/oghttp2_session.cc
+++ b/quiche/http2/adapter/oghttp2_session.cc
@@ -348,9 +348,7 @@
           options.should_window_update_fn,
           /*update_window_on_notify=*/false),
       max_outbound_concurrent_streams_(
-          options.remote_max_concurrent_streams
-              ? options.remote_max_concurrent_streams.value()
-              : 100u) {
+          options.remote_max_concurrent_streams.value_or(100u)) {
   decoder_.set_visitor(&receive_logger_);
   if (options_.max_header_list_bytes) {
     // Limit buffering of encoded HPACK data to 2x the decoded limit.
@@ -365,7 +363,7 @@
                           spdy::kHttp2ConnectionHeaderPrefixSize};
   }
   if (options_.max_header_field_size.has_value()) {
-    headers_handler_.SetMaxFieldSize(options_.max_header_field_size.value());
+    headers_handler_.SetMaxFieldSize(*options_.max_header_field_size);
   }
   headers_handler_.SetAllowObsText(options_.allow_obs_text);
 }
@@ -740,7 +738,7 @@
       const bool is_settings_ack = (flags & ACK_FLAG);
       if (is_settings_ack && encoder_header_table_capacity_when_acking_) {
         framer_.UpdateHeaderEncoderTableSize(
-            encoder_header_table_capacity_when_acking_.value());
+            *encoder_header_table_capacity_when_acking_);
         encoder_header_table_capacity_when_acking_ = absl::nullopt;
       } else if (!is_settings_ack) {
         sent_non_ack_settings_ = true;
@@ -1864,8 +1862,7 @@
     } else {
       return HeaderType::REQUEST_TRAILER;
     }
-  } else if (!current_type ||
-             current_type.value() == HeaderType::RESPONSE_100) {
+  } else if (!current_type || *current_type == HeaderType::RESPONSE_100) {
     return HeaderType::RESPONSE;
   } else {
     return HeaderType::RESPONSE_TRAILER;
diff --git a/quiche/quic/core/crypto/certificate_view.cc b/quiche/quic/core/crypto/certificate_view.cc
index b02c58c..456d94b 100644
--- a/quiche/quic/core/crypto/certificate_view.cc
+++ b/quiche/quic/core/crypto/certificate_view.cc
@@ -260,7 +260,7 @@
           QuicheTextUtils::Base64Decode(encoded_message_contents);
       if (data.has_value()) {
         result.status = PemReadResult::kOk;
-        result.contents = data.value();
+        result.contents = *data;
       } else {
         result.status = PemReadResult::kError;
       }
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config.cc b/quiche/quic/core/crypto/quic_crypto_server_config.cc
index f3025ec..2599f5b 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config.cc
+++ b/quiche/quic/core/crypto/quic_crypto_server_config.cc
@@ -915,7 +915,7 @@
     context->Fail(QUIC_CRYPTO_INTERNAL_ERROR, "Failed to get certs");
     return;
   }
-  hkdf_suffix.append(context->signed_config()->chain->certs.at(0));
+  hkdf_suffix.append(context->signed_config()->chain->certs[0]);
 
   absl::string_view cetv_ciphertext;
   if (configs.requested->channel_id_enabled &&
@@ -1873,7 +1873,7 @@
   if (client_hello.GetUint64(kXLCT, &hash_from_client) != QUIC_NO_ERROR) {
     return false;
   }
-  return CryptoUtils::ComputeLeafCertHash(certs.at(0)) == hash_from_client;
+  return CryptoUtils::ComputeLeafCertHash(certs[0]) == hash_from_client;
 }
 
 bool QuicCryptoServerConfig::IsNextConfigReady(QuicWallTime now) const {
diff --git a/quiche/quic/core/crypto/transport_parameters.cc b/quiche/quic/core/crypto/transport_parameters.cc
index ebaa070..1726ad3 100644
--- a/quiche/quic/core/crypto/transport_parameters.cc
+++ b/quiche/quic/core/crypto/transport_parameters.cc
@@ -384,14 +384,14 @@
     rv += "Client";
   }
   if (legacy_version_information.has_value()) {
-    rv += " " + legacy_version_information.value().ToString();
+    rv += " " + legacy_version_information->ToString();
   }
   if (version_information.has_value()) {
-    rv += " " + version_information.value().ToString();
+    rv += " " + version_information->ToString();
   }
   if (original_destination_connection_id.has_value()) {
     rv += " " + TransportParameterIdToString(kOriginalDestinationConnectionId) +
-          " " + original_destination_connection_id.value().ToString();
+          " " + original_destination_connection_id->ToString();
   }
   rv += max_idle_timeout_ms.ToString(/*for_use_in_list=*/true);
   if (!stateless_reset_token.empty()) {
@@ -420,23 +420,23 @@
   rv += active_connection_id_limit.ToString(/*for_use_in_list=*/true);
   if (initial_source_connection_id.has_value()) {
     rv += " " + TransportParameterIdToString(kInitialSourceConnectionId) + " " +
-          initial_source_connection_id.value().ToString();
+          initial_source_connection_id->ToString();
   }
   if (retry_source_connection_id.has_value()) {
     rv += " " + TransportParameterIdToString(kRetrySourceConnectionId) + " " +
-          retry_source_connection_id.value().ToString();
+          retry_source_connection_id->ToString();
   }
   rv += max_datagram_frame_size.ToString(/*for_use_in_list=*/true);
   if (google_handshake_message.has_value()) {
     absl::StrAppend(&rv, " ",
                     TransportParameterIdToString(kGoogleHandshakeMessage),
-                    " length: ", google_handshake_message.value().length());
+                    " length: ", google_handshake_message->length());
   }
   rv += initial_round_trip_time_us.ToString(/*for_use_in_list=*/true);
   if (google_connection_options.has_value()) {
     rv += " " + TransportParameterIdToString(kGoogleConnectionOptions) + " ";
     bool first = true;
-    for (const QuicTag& connection_option : google_connection_options.value()) {
+    for (const QuicTag& connection_option : *google_connection_options) {
       if (first) {
         first = false;
       } else {
@@ -642,9 +642,9 @@
   }
   if (version_information.has_value()) {
     const QuicVersionLabel& chosen_version =
-        version_information.value().chosen_version;
+        version_information->chosen_version;
     const QuicVersionLabelVector& other_versions =
-        version_information.value().other_versions;
+        version_information->other_versions;
     if (chosen_version == 0) {
       *error_details = "Invalid chosen version";
       return false;
@@ -690,9 +690,9 @@
     return false;
   }
   if (!in.legacy_version_information.has_value() ||
-      in.legacy_version_information.value().version == 0 ||
+      in.legacy_version_information->version == 0 ||
       (in.perspective == Perspective::IS_SERVER &&
-       in.legacy_version_information.value().supported_versions.empty())) {
+       in.legacy_version_information->supported_versions.empty())) {
     QUIC_BUG(missing versions) << "Refusing to serialize without versions";
     return false;
   }
@@ -781,27 +781,27 @@
   // google_connection_options.
   if (in.google_connection_options.has_value()) {
     max_transport_param_length +=
-        in.google_connection_options.value().size() * sizeof(QuicTag);
+        in.google_connection_options->size() * sizeof(QuicTag);
   }
   // Google-specific version extension.
   if (in.legacy_version_information.has_value()) {
     max_transport_param_length +=
-        sizeof(in.legacy_version_information.value().version) +
+        sizeof(in.legacy_version_information->version) +
         1 /* versions length */ +
-        in.legacy_version_information.value().supported_versions.size() *
+        in.legacy_version_information->supported_versions.size() *
             sizeof(QuicVersionLabel);
   }
   // version_information.
   if (in.version_information.has_value()) {
     max_transport_param_length +=
-        sizeof(in.version_information.value().chosen_version) +
+        sizeof(in.version_information->chosen_version) +
         // Add one for the added GREASE version.
-        (in.version_information.value().other_versions.size() + 1) *
+        (in.version_information->other_versions.size() + 1) *
             sizeof(QuicVersionLabel);
   }
   // google_handshake_message.
   if (in.google_handshake_message.has_value()) {
-    max_transport_param_length += in.google_handshake_message.value().length();
+    max_transport_param_length += in.google_handshake_message->length();
   }
 
   // Add a random GREASE transport parameter, as defined in the
@@ -846,7 +846,7 @@
         if (in.original_destination_connection_id.has_value()) {
           QUICHE_DCHECK_EQ(Perspective::IS_SERVER, in.perspective);
           QuicConnectionId original_destination_connection_id =
-              in.original_destination_connection_id.value();
+              *in.original_destination_connection_id;
           if (!writer.WriteVarInt62(
                   TransportParameters::kOriginalDestinationConnectionId) ||
               !writer.WriteStringPieceVarInt62(absl::string_view(
@@ -989,11 +989,10 @@
         if (in.google_handshake_message.has_value()) {
           if (!writer.WriteVarInt62(
                   TransportParameters::kGoogleHandshakeMessage) ||
-              !writer.WriteStringPieceVarInt62(
-                  in.google_handshake_message.value())) {
+              !writer.WriteStringPieceVarInt62(*in.google_handshake_message)) {
             QUIC_BUG(Failed to write google_handshake_message)
                 << "Failed to write google_handshake_message: "
-                << in.google_handshake_message.value() << " for " << in;
+                << *in.google_handshake_message << " for " << in;
             return false;
           }
         }
@@ -1066,7 +1065,7 @@
       case TransportParameters::kInitialSourceConnectionId: {
         if (in.initial_source_connection_id.has_value()) {
           QuicConnectionId initial_source_connection_id =
-              in.initial_source_connection_id.value();
+              *in.initial_source_connection_id;
           if (!writer.WriteVarInt62(
                   TransportParameters::kInitialSourceConnectionId) ||
               !writer.WriteStringPieceVarInt62(
@@ -1084,7 +1083,7 @@
         if (in.retry_source_connection_id.has_value()) {
           QUICHE_DCHECK_EQ(Perspective::IS_SERVER, in.perspective);
           QuicConnectionId retry_source_connection_id =
-              in.retry_source_connection_id.value();
+              *in.retry_source_connection_id;
           if (!writer.WriteVarInt62(
                   TransportParameters::kRetrySourceConnectionId) ||
               !writer.WriteStringPieceVarInt62(
@@ -1100,11 +1099,10 @@
       // Google-specific connection options.
       case TransportParameters::kGoogleConnectionOptions: {
         if (in.google_connection_options.has_value()) {
-          static_assert(
-              sizeof(in.google_connection_options.value().front()) == 4,
-              "bad size");
+          static_assert(sizeof(in.google_connection_options->front()) == 4,
+                        "bad size");
           uint64_t connection_options_length =
-              in.google_connection_options.value().size() * 4;
+              in.google_connection_options->size() * 4;
           if (!writer.WriteVarInt62(
                   TransportParameters::kGoogleConnectionOptions) ||
               !writer.WriteVarInt62(
@@ -1115,7 +1113,7 @@
             return false;
           }
           for (const QuicTag& connection_option :
-               in.google_connection_options.value()) {
+               *in.google_connection_options) {
             if (!writer.WriteTag(connection_option)) {
               QUIC_BUG(Failed to write google_connection_option)
                   << "Failed to write google_connection_option "
@@ -1133,32 +1131,31 @@
         static_assert(sizeof(QuicVersionLabel) == sizeof(uint32_t),
                       "bad length");
         uint64_t google_version_length =
-            sizeof(in.legacy_version_information.value().version);
+            sizeof(in.legacy_version_information->version);
         if (in.perspective == Perspective::IS_SERVER) {
           google_version_length +=
               /* versions length */ sizeof(uint8_t) +
-              sizeof(QuicVersionLabel) * in.legacy_version_information.value()
-                                             .supported_versions.size();
+              sizeof(QuicVersionLabel) *
+                  in.legacy_version_information->supported_versions.size();
         }
         if (!writer.WriteVarInt62(TransportParameters::kGoogleQuicVersion) ||
             !writer.WriteVarInt62(
                 /* transport parameter length */ google_version_length) ||
-            !writer.WriteUInt32(
-                in.legacy_version_information.value().version)) {
+            !writer.WriteUInt32(in.legacy_version_information->version)) {
           QUIC_BUG(Failed to write Google version extension)
               << "Failed to write Google version extension for " << in;
           return false;
         }
         if (in.perspective == Perspective::IS_SERVER) {
-          if (!writer.WriteUInt8(sizeof(QuicVersionLabel) *
-                                 in.legacy_version_information.value()
-                                     .supported_versions.size())) {
+          if (!writer.WriteUInt8(
+                  sizeof(QuicVersionLabel) *
+                  in.legacy_version_information->supported_versions.size())) {
             QUIC_BUG(Failed to write versions length)
                 << "Failed to write versions length for " << in;
             return false;
           }
           for (QuicVersionLabel version_label :
-               in.legacy_version_information.value().supported_versions) {
+               in.legacy_version_information->supported_versions) {
             if (!writer.WriteUInt32(version_label)) {
               QUIC_BUG(Failed to write supported version)
                   << "Failed to write supported version for " << in;
@@ -1175,7 +1172,7 @@
         static_assert(sizeof(QuicVersionLabel) == sizeof(uint32_t),
                       "bad length");
         QuicVersionLabelVector other_versions =
-            in.version_information.value().other_versions;
+            in.version_information->other_versions;
         // Insert one GREASE version at a random index.
         const size_t grease_index =
             random->InsecureRandUint64() % (other_versions.size() + 1);
@@ -1183,13 +1180,12 @@
             other_versions.begin() + grease_index,
             CreateQuicVersionLabel(QuicVersionReservedForNegotiation()));
         const uint64_t version_information_length =
-            sizeof(in.version_information.value().chosen_version) +
+            sizeof(in.version_information->chosen_version) +
             sizeof(QuicVersionLabel) * other_versions.size();
         if (!writer.WriteVarInt62(TransportParameters::kVersionInformation) ||
             !writer.WriteVarInt62(
                 /* transport parameter length */ version_information_length) ||
-            !writer.WriteUInt32(
-                in.version_information.value().chosen_version)) {
+            !writer.WriteUInt32(in.version_information->chosen_version)) {
           QUIC_BUG(Failed to write chosen version)
               << "Failed to write chosen version for " << in;
           return false;
@@ -1450,7 +1446,7 @@
             *error_details = "Failed to read a google_connection_options";
             return false;
           }
-          out->google_connection_options.value().push_back(connection_option);
+          out->google_connection_options->push_back(connection_option);
         }
       } break;
       case TransportParameters::kGoogleQuicVersion: {
@@ -1459,7 +1455,7 @@
               TransportParameters::LegacyVersionInformation();
         }
         if (!value_reader.ReadUInt32(
-                &out->legacy_version_information.value().version)) {
+                &out->legacy_version_information->version)) {
           *error_details = "Failed to read Google version extension version";
           return false;
         }
@@ -1476,8 +1472,8 @@
               *error_details = "Failed to parse Google supported version";
               return false;
             }
-            out->legacy_version_information.value()
-                .supported_versions.push_back(version);
+            out->legacy_version_information->supported_versions.push_back(
+                version);
           }
         }
       } break;
@@ -1488,7 +1484,7 @@
         }
         out->version_information = TransportParameters::VersionInformation();
         if (!value_reader.ReadUInt32(
-                &out->version_information.value().chosen_version)) {
+                &out->version_information->chosen_version)) {
           *error_details = "Failed to read chosen version";
           return false;
         }
@@ -1498,8 +1494,7 @@
             *error_details = "Failed to parse other version";
             return false;
           }
-          out->version_information.value().other_versions.push_back(
-              other_version);
+          out->version_information->other_versions.push_back(other_version);
         }
       } break;
       case TransportParameters::kMinAckDelay:
diff --git a/quiche/quic/core/deterministic_connection_id_generator.cc b/quiche/quic/core/deterministic_connection_id_generator.cc
index fd86dc7..619ede6 100644
--- a/quiche/quic/core/deterministic_connection_id_generator.cc
+++ b/quiche/quic/core/deterministic_connection_id_generator.cc
@@ -60,13 +60,16 @@
   absl::optional<QuicConnectionId> new_connection_id =
       GenerateNextConnectionId(original);
   // Verify that ReplaceShortServerConnectionId is deterministic.
-  QUICHE_DCHECK(new_connection_id.has_value());
+  if (!new_connection_id.has_value()) {
+    QUIC_BUG(unset_next_connection_id);
+    return absl::nullopt;
+  }
   QUICHE_DCHECK_EQ(
       *new_connection_id,
       static_cast<QuicConnectionId>(*GenerateNextConnectionId(original)));
   QUICHE_DCHECK_EQ(expected_connection_id_length_, new_connection_id->length());
   QUIC_DLOG(INFO) << "Replacing incoming connection ID " << original << " with "
-                  << new_connection_id.value();
+                  << *new_connection_id;
   return new_connection_id;
 }
 
diff --git a/quiche/quic/core/http/quic_server_session_base.cc b/quiche/quic/core/http/quic_server_session_base.cc
index 675f209..5816eb3 100644
--- a/quiche/quic/core/http/quic_server_session_base.cc
+++ b/quiche/quic/core/http/quic_server_session_base.cc
@@ -203,7 +203,7 @@
               bandwidth_estimate_sent_to_client_),
           cached_network_params->bandwidth_estimate_bytes_per_second());
 
-      crypto_stream_->SendServerConfigUpdate(&cached_network_params.value());
+      crypto_stream_->SendServerConfigUpdate(&*cached_network_params);
 
       connection()->OnSendConnectionState(*cached_network_params);
     }
diff --git a/quiche/quic/core/http/quic_spdy_session.cc b/quiche/quic/core/http/quic_spdy_session.cc
index 4789073..03f65db 100644
--- a/quiche/quic/core/http/quic_spdy_session.cc
+++ b/quiche/quic/core/http/quic_spdy_session.cc
@@ -747,12 +747,12 @@
       << "HTTP/3 GOAWAY received on version " << version();
 
   if (last_received_http3_goaway_id_.has_value() &&
-      id > last_received_http3_goaway_id_.value()) {
+      id > *last_received_http3_goaway_id_) {
     CloseConnectionWithDetails(
         QUIC_HTTP_GOAWAY_ID_LARGER_THAN_PREVIOUS,
         absl::StrCat("GOAWAY received with ID ", id,
                      " greater than previously received ID ",
-                     last_received_http3_goaway_id_.value()));
+                     *last_received_http3_goaway_id_));
     return;
   }
   last_received_http3_goaway_id_ = id;
@@ -832,7 +832,7 @@
       QuicUtils::GetMaxClientInitiatedBidirectionalStreamId(
           transport_version());
   if (last_sent_http3_goaway_id_.has_value() &&
-      last_sent_http3_goaway_id_.value() <= stream_id) {
+      *last_sent_http3_goaway_id_ <= stream_id) {
     // Do not send GOAWAY frame with a higher id, because it is forbidden.
     // Do not send one with same stream id as before, since frames on the
     // control stream are guaranteed to be processed in order.
@@ -1643,7 +1643,7 @@
     stream_id += QuicUtils::StreamIdDelta(transport_version());
   }
   if (last_sent_http3_goaway_id_.has_value() &&
-      last_sent_http3_goaway_id_.value() <= stream_id) {
+      *last_sent_http3_goaway_id_ <= stream_id) {
     // Do not send GOAWAY frame with a higher id, because it is forbidden.
     // Do not send one with same stream id as before, since frames on the
     // control stream are guaranteed to be processed in order.
diff --git a/quiche/quic/core/io/event_loop_connecting_client_socket.cc b/quiche/quic/core/io/event_loop_connecting_client_socket.cc
index aefa353..53dfb1f 100644
--- a/quiche/quic/core/io/event_loop_connecting_client_socket.cc
+++ b/quiche/quic/core/io/event_loop_connecting_client_socket.cc
@@ -286,9 +286,9 @@
                     << " with error: " << descriptor.status();
     return descriptor.status();
   }
-  QUICHE_DCHECK_NE(descriptor.value(), kInvalidSocketFd);
+  QUICHE_DCHECK_NE(*descriptor, kInvalidSocketFd);
 
-  descriptor_ = descriptor.value();
+  descriptor_ = *descriptor;
 
   if (async_visitor_) {
     bool registered;
@@ -443,35 +443,34 @@
   QUICHE_DCHECK_NE(descriptor_, kInvalidSocketFd);
   QUICHE_DCHECK(connect_status_ == ConnectStatus::kConnected);
   QUICHE_CHECK(receive_max_size_.has_value());
-  QUICHE_DCHECK_GE(receive_max_size_.value(), 1u);
-  QUICHE_DCHECK_LE(receive_max_size_.value(),
-                   std::numeric_limits<size_t>::max());
+  QUICHE_DCHECK_GE(*receive_max_size_, 1u);
+  QUICHE_DCHECK_LE(*receive_max_size_, std::numeric_limits<size_t>::max());
 
   // Before allocating a buffer, do a 1-byte peek to determine if needed.
-  if (receive_max_size_.value() > 1) {
+  if (*receive_max_size_ > 1) {
     absl::StatusOr<bool> peek_data = OneBytePeek();
     if (!peek_data.ok()) {
       if (!absl::IsUnavailable(peek_data.status())) {
         receive_max_size_.reset();
       }
       return peek_data.status();
-    } else if (!peek_data.value()) {
+    } else if (!*peek_data) {
       receive_max_size_.reset();
       return quiche::QuicheMemSlice();
     }
   }
 
-  quiche::QuicheBuffer buffer(buffer_allocator_, receive_max_size_.value());
+  quiche::QuicheBuffer buffer(buffer_allocator_, *receive_max_size_);
   absl::StatusOr<absl::Span<char>> received = socket_api::Receive(
       descriptor_, absl::MakeSpan(buffer.data(), buffer.size()));
 
   if (received.ok()) {
-    QUICHE_DCHECK_LE(received.value().size(), buffer.size());
-    QUICHE_DCHECK_EQ(received.value().data(), buffer.data());
+    QUICHE_DCHECK_LE(received->size(), buffer.size());
+    QUICHE_DCHECK_EQ(received->data(), buffer.data());
 
     receive_max_size_.reset();
     return quiche::QuicheMemSlice(
-        quiche::QuicheBuffer(buffer.Release(), received.value().size()));
+        quiche::QuicheBuffer(buffer.Release(), received->size()));
   } else {
     if (!absl::IsUnavailable(received.status())) {
       QUICHE_DVLOG(1) << "Failed to receive from socket to address: "
@@ -510,7 +509,7 @@
   if (!peek_received.ok()) {
     return peek_received.status();
   } else {
-    return !peek_received.value().empty();
+    return !peek_received->empty();
   }
 }
 
@@ -574,14 +573,14 @@
         socket_api::Send(descriptor_, send_remaining_);
 
     if (remainder.ok()) {
-      QUICHE_DCHECK(remainder.value().empty() ||
-                    (remainder.value().data() >= send_remaining_.data() &&
-                     remainder.value().data() <
+      QUICHE_DCHECK(remainder->empty() ||
+                    (remainder->data() >= send_remaining_.data() &&
+                     remainder->data() <
                          send_remaining_.data() + send_remaining_.size()));
-      QUICHE_DCHECK(remainder.value().empty() ||
-                    (remainder.value().data() + remainder.value().size() ==
+      QUICHE_DCHECK(remainder->empty() ||
+                    (remainder->data() + remainder->size() ==
                      send_remaining_.data() + send_remaining_.size()));
-      send_remaining_ = remainder.value();
+      send_remaining_ = *remainder;
     } else {
       if (!absl::IsUnavailable(remainder.status())) {
         QUICHE_DVLOG(1) << "Failed to send to socket to address: "
diff --git a/quiche/quic/core/io/socket.cc b/quiche/quic/core/io/socket.cc
index d914ffd..0118003 100644
--- a/quiche/quic/core/io/socket.cc
+++ b/quiche/quic/core/io/socket.cc
@@ -44,7 +44,7 @@
       ValidateAndConvertAddress(peer_addr, peer_addr_len);
 
   if (peer_address.ok()) {
-    return AcceptResult{connection_socket, peer_address.value()};
+    return AcceptResult{connection_socket, *peer_address};
   } else {
     return peer_address.status();
   }
@@ -201,13 +201,13 @@
   // If non-blocking could not be set directly on socket acceptance, need to
   // do it now.
   absl::Status set_non_blocking_result =
-      SetSocketBlocking(accept_result.value().fd, /*blocking=*/false);
+      SetSocketBlocking(accept_result->fd, /*blocking=*/false);
   if (!set_non_blocking_result.ok()) {
     QUICHE_LOG_FIRST_N(ERROR, 100)
         << "Failed to set socket " << fd << " as non-blocking on acceptance.";
-    if (!Close(accept_result.value().fd).ok()) {
+    if (!Close(accept_result->fd).ok()) {
       QUICHE_LOG_FIRST_N(ERROR, 100)
-          << "Failed to close socket " << accept_result.value().fd
+          << "Failed to close socket " << accept_result->fd
           << " after error setting non-blocking on acceptance.";
     }
     return set_non_blocking_result;
diff --git a/quiche/quic/core/io/socket_posix.inc b/quiche/quic/core/io/socket_posix.inc
index c98e2ef..2ce98b4 100644
--- a/quiche/quic/core/io/socket_posix.inc
+++ b/quiche/quic/core/io/socket_posix.inc
@@ -192,7 +192,7 @@
       ValidateAndConvertAddress(peer_addr, peer_addr_len);
 
   if (peer_address.ok()) {
-    return AcceptResult{connection_socket, peer_address.value()};
+    return AcceptResult{connection_socket, *peer_address};
   } else {
     return peer_address.status();
   }
@@ -228,13 +228,13 @@
   // If non-blocking could not be set directly on socket creation, need to do
   // it now.
   absl::Status set_non_blocking_result =
-      SetSocketBlocking(socket.value(), /*blocking=*/false);
+      SetSocketBlocking(*socket, /*blocking=*/false);
   if (!set_non_blocking_result.ok()) {
-    QUICHE_LOG_FIRST_N(ERROR, 100) << "Failed to set socket " << socket.value()
+    QUICHE_LOG_FIRST_N(ERROR, 100) << "Failed to set socket " << *socket
                                    << " as non-blocking on creation.";
-    if (!Close(socket.value()).ok()) {
+    if (!Close(*socket).ok()) {
       QUICHE_LOG_FIRST_N(ERROR, 100)
-          << "Failed to close socket " << socket.value()
+          << "Failed to close socket " << *socket
           << " after set-non-blocking error on creation.";
     }
     return set_non_blocking_result;
diff --git a/quiche/quic/core/quic_config.cc b/quiche/quic/core/quic_config.cc
index 43f4bbd..f0d78ba 100644
--- a/quiche/quic/core/quic_config.cc
+++ b/quiche/quic/core/quic_config.cc
@@ -556,7 +556,7 @@
   if (!received_max_idle_timeout_.has_value()) {
     return max_idle_timeout_to_send_;
   }
-  return received_max_idle_timeout_.value();
+  return *received_max_idle_timeout_;
 }
 
 void QuicConfig::SetMaxBidirectionalStreamsToSend(uint32_t max_streams) {
@@ -934,7 +934,7 @@
     QUIC_BUG(quic_bug_10575_13) << "No received original connection ID";
     return EmptyQuicConnectionId();
   }
-  return received_original_destination_connection_id_.value();
+  return *received_original_destination_connection_id_;
 }
 
 void QuicConfig::SetInitialSourceConnectionIdToSend(
@@ -951,7 +951,7 @@
     QUIC_BUG(quic_bug_10575_14) << "No received initial source connection ID";
     return EmptyQuicConnectionId();
   }
-  return received_initial_source_connection_id_.value();
+  return *received_initial_source_connection_id_;
 }
 
 void QuicConfig::SetRetrySourceConnectionIdToSend(
@@ -968,7 +968,7 @@
     QUIC_BUG(quic_bug_10575_15) << "No received retry source connection ID";
     return EmptyQuicConnectionId();
   }
-  return received_retry_source_connection_id_.value();
+  return *received_retry_source_connection_id_;
 }
 
 void QuicConfig::SetStatelessResetTokenToSend(
@@ -1161,7 +1161,7 @@
 bool QuicConfig::FillTransportParameters(TransportParameters* params) const {
   if (original_destination_connection_id_to_send_.has_value()) {
     params->original_destination_connection_id =
-        original_destination_connection_id_to_send_.value();
+        *original_destination_connection_id_to_send_;
   }
 
   params->max_idle_timeout_ms.set_value(
@@ -1238,12 +1238,11 @@
 
   if (initial_source_connection_id_to_send_.has_value()) {
     params->initial_source_connection_id =
-        initial_source_connection_id_to_send_.value();
+        *initial_source_connection_id_to_send_;
   }
 
   if (retry_source_connection_id_to_send_.has_value()) {
-    params->retry_source_connection_id =
-        retry_source_connection_id_to_send_.value();
+    params->retry_source_connection_id = *retry_source_connection_id_to_send_;
   }
 
   if (initial_round_trip_time_us_.HasSendValue()) {
@@ -1269,7 +1268,7 @@
     std::string* error_details) {
   if (!is_resumption && params.original_destination_connection_id.has_value()) {
     received_original_destination_connection_id_ =
-        params.original_destination_connection_id.value();
+        *params.original_destination_connection_id;
   }
 
   if (params.max_idle_timeout_ms.value() > 0 &&
@@ -1374,11 +1373,10 @@
   if (!is_resumption) {
     if (params.initial_source_connection_id.has_value()) {
       received_initial_source_connection_id_ =
-          params.initial_source_connection_id.value();
+          *params.initial_source_connection_id;
     }
     if (params.retry_source_connection_id.has_value()) {
-      received_retry_source_connection_id_ =
-          params.retry_source_connection_id.value();
+      received_retry_source_connection_id_ = *params.retry_source_connection_id;
     }
   }
 
@@ -1387,8 +1385,7 @@
         params.initial_round_trip_time_us.value());
   }
   if (params.google_connection_options.has_value()) {
-    connection_options_.SetReceivedValues(
-        params.google_connection_options.value());
+    connection_options_.SetReceivedValues(*params.google_connection_options);
   }
   if (params.google_handshake_message.has_value()) {
     received_google_handshake_message_ = params.google_handshake_message;
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index 8a0d56d..513f4d0 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -490,7 +490,7 @@
       // connection ID from the config matches the one from the RETRY.
       if (!config.HasReceivedRetrySourceConnectionId() ||
           config.ReceivedRetrySourceConnectionId() !=
-              retry_source_connection_id_.value()) {
+              *retry_source_connection_id_) {
         std::string received_value;
         if (config.HasReceivedRetrySourceConnectionId()) {
           received_value = config.ReceivedRetrySourceConnectionId().ToString();
@@ -499,8 +499,8 @@
         }
         std::string error_details =
             absl::StrCat("Bad retry_source_connection_id: expected ",
-                         retry_source_connection_id_.value().ToString(),
-                         ", received ", received_value);
+                         retry_source_connection_id_->ToString(), ", received ",
+                         received_value);
         CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details,
                         ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
         return false;
@@ -925,7 +925,7 @@
     original_destination_connection_id_ = default_path_.server_connection_id;
   }
   QUICHE_DCHECK(!retry_source_connection_id_.has_value())
-      << retry_source_connection_id_.value();
+      << *retry_source_connection_id_;
   retry_source_connection_id_ = new_connection_id;
   ReplaceInitialServerConnectionId(new_connection_id);
   packet_creator_.SetRetryToken(retry_token);
@@ -946,7 +946,7 @@
                    default_path_.server_connection_id);
   InstallInitialCrypters(original_destination_connection_id);
   QUICHE_DCHECK(!original_destination_connection_id_.has_value())
-      << original_destination_connection_id_.value();
+      << *original_destination_connection_id_;
   original_destination_connection_id_ = original_destination_connection_id;
   original_destination_connection_id_replacement_ =
       default_path_.server_connection_id;
@@ -954,7 +954,7 @@
 
 QuicConnectionId QuicConnection::GetOriginalDestinationConnectionId() const {
   if (original_destination_connection_id_.has_value()) {
-    return original_destination_connection_id_.value();
+    return *original_destination_connection_id_;
   }
   return default_path_.server_connection_id;
 }
@@ -5296,13 +5296,16 @@
 
     if (alternative_path_.peer_address.host() ==
             current_effective_peer_address.host() &&
-        alternative_path_.send_algorithm != nullptr) {
+        alternative_path_.send_algorithm != nullptr &&
+        alternative_path_.rtt_stats.has_value()) {
       // Update the default path with the congestion controller of the
       // alternative path.
       sent_packet_manager_.SetSendAlgorithm(
           alternative_path_.send_algorithm.release());
-      sent_packet_manager_.SetRttStats(
-          std::move(alternative_path_.rtt_stats).value());
+      sent_packet_manager_.SetRttStats(*alternative_path_.rtt_stats);
+
+      // Explicitly clear alternative_path_.rtt_stats
+      alternative_path_.rtt_stats = absl::nullopt;
     }
   }
   // Update to the new peer address.
@@ -6946,13 +6949,13 @@
   }
   // Add the original connection ID
   if (std::find(result.begin(), result.end(),
-                original_destination_connection_id_.value()) != result.end()) {
+                *original_destination_connection_id_) != result.end()) {
     QUIC_BUG(quic_unexpected_original_destination_connection_id)
         << "original_destination_connection_id: "
-        << original_destination_connection_id_.value()
+        << *original_destination_connection_id_
         << " is unexpectedly in active list";
   } else {
-    result.insert(result.end(), original_destination_connection_id_.value());
+    result.insert(result.end(), *original_destination_connection_id_);
   }
   return result;
 }
@@ -7098,7 +7101,7 @@
     send_algorithm = std::move(other.send_algorithm);
     if (other.rtt_stats.has_value()) {
       rtt_stats.emplace();
-      rtt_stats->CloneFrom(other.rtt_stats.value());
+      rtt_stats->CloneFrom(*other.rtt_stats);
     } else {
       rtt_stats.reset();
     }
@@ -7301,12 +7304,15 @@
   if (alternative_path_.send_algorithm != nullptr) {
     sent_packet_manager_.SetSendAlgorithm(
         alternative_path_.send_algorithm.release());
-    sent_packet_manager_.SetRttStats(alternative_path_.rtt_stats.value());
   } else {
     QUIC_BUG(quic_bug_10511_42)
         << "Fail to store congestion controller before migration.";
   }
 
+  if (alternative_path_.rtt_stats.has_value()) {
+    sent_packet_manager_.SetRttStats(*alternative_path_.rtt_stats);
+  }
+
   UpdatePeerAddress(original_direct_peer_address);
   SetDefaultPathState(std::move(alternative_path_));
 
diff --git a/quiche/quic/core/quic_framer.cc b/quiche/quic/core/quic_framer.cc
index a3f92dd..b17b8c9 100644
--- a/quiche/quic/core/quic_framer.cc
+++ b/quiche/quic/core/quic_framer.cc
@@ -5522,7 +5522,7 @@
                       << ", effective_prev_time:" << *effective_prev_time
                       << ", recv_time:" << receive_timestamp;
         time_delta = time_delta >> receive_timestamps_exponent_;
-        effective_prev_time = effective_prev_time.value() -
+        effective_prev_time = *effective_prev_time -
                               QuicTime::Delta::FromMicroseconds(
                                   time_delta << receive_timestamps_exponent_);
       } else {
diff --git a/quiche/quic/core/quic_interval_deque.h b/quiche/quic/core/quic_interval_deque.h
index 875c54d..c4bd49c 100644
--- a/quiche/quic/core/quic_interval_deque.h
+++ b/quiche/quic/core/quic_interval_deque.h
@@ -167,7 +167,7 @@
       }
       index_++;
       if (deque_->cached_index_.has_value()) {
-        const std::size_t cached_index = deque_->cached_index_.value();
+        const std::size_t cached_index = *deque_->cached_index_;
         // If all items are iterated then reset the |cached_index_|
         if (index_ == container_size) {
           deque_->cached_index_.reset();
@@ -286,7 +286,7 @@
     cached_index_.reset();
   }
   if (cached_index_.value_or(0) > 0) {
-    cached_index_ = cached_index_.value() - 1;
+    cached_index_ = *cached_index_ - 1;
   }
 }
 
@@ -309,7 +309,7 @@
     return Search(interval_begin, 0, container_.size());
   }
 
-  const std::size_t cached_index = cached_index_.value();
+  const std::size_t cached_index = *cached_index_;
   QUICHE_DCHECK(cached_index < container_.size());
 
   const QuicInterval<size_t> cached_interval =
diff --git a/quiche/quic/core/quic_packet_creator.cc b/quiche/quic/core/quic_packet_creator.cc
index 37baedf..388fed7 100644
--- a/quiche/quic/core/quic_packet_creator.cc
+++ b/quiche/quic/core/quic_packet_creator.cc
@@ -552,10 +552,10 @@
       !packet_.initial_header.has_value()) {
     QUIC_BUG(missing initial packet header)
         << "initial serialized packet does not have header populated";
-  } else if (packet.initial_header.value() != packet_.initial_header.value()) {
+  } else if (*packet.initial_header != *packet_.initial_header) {
     QUIC_BUG(initial packet header changed before reserialization)
-        << ENDPOINT << "original header: " << packet.initial_header.value()
-        << ", new header: " << packet_.initial_header.value();
+        << ENDPOINT << "original header: " << *packet.initial_header
+        << ", new header: " << *packet_.initial_header;
   }
   const size_t encrypted_length = packet_.encrypted_length;
   // Clear frames in packet_. No need to DeleteFrames since frames are owned by
@@ -846,7 +846,7 @@
   absl::optional<size_t> length_with_chaos_protection =
       MaybeBuildDataPacketWithChaosProtection(header, encrypted_buffer.buffer);
   if (length_with_chaos_protection.has_value()) {
-    length = length_with_chaos_protection.value();
+    length = *length_with_chaos_protection;
   } else {
     length = framer_->BuildDataPacket(header, queued_frames_,
                                       encrypted_buffer.buffer, packet_size_,
diff --git a/quiche/quic/core/quic_sent_packet_manager.cc b/quiche/quic/core/quic_sent_packet_manager.cc
index 6050860..5786764 100644
--- a/quiche/quic/core/quic_sent_packet_manager.cc
+++ b/quiche/quic/core/quic_sent_packet_manager.cc
@@ -1444,7 +1444,7 @@
                                last_ack_frame_, ack_receive_time, rtt_updated_,
                                prior_bytes_in_flight, valid_ecn_counts);
   if (valid_ecn_counts.has_value()) {
-    peer_ack_ecn_counts_[acked_packet_number_space] = valid_ecn_counts.value();
+    peer_ack_ecn_counts_[acked_packet_number_space] = *valid_ecn_counts;
   }
   return acked_new_packet ? PACKETS_NEWLY_ACKED : NO_PACKETS_NEWLY_ACKED;
 }
diff --git a/quiche/quic/core/quic_session.cc b/quiche/quic/core/quic_session.cc
index b57d3b1..462a564 100644
--- a/quiche/quic/core/quic_session.cc
+++ b/quiche/quic/core/quic_session.cc
@@ -783,7 +783,7 @@
   std::stringstream ss;
   ss << on_closed_frame_;
   if (source_.has_value()) {
-    ss << " " << ConnectionCloseSourceToString(source_.value());
+    ss << " " << ConnectionCloseSourceToString(*source_);
   }
   return ss.str();
 }
@@ -1344,8 +1344,7 @@
           config_.SetPreferredAddressConnectionIdAndTokenToSend(
               frame->connection_id, frame->stateless_reset_token);
         }
-        connection_->set_sent_server_preferred_address(
-            preferred_address.value());
+        connection_->set_sent_server_preferred_address(*preferred_address);
       }
       // Clear the alternative address of the other address family in the
       // config.
@@ -1720,8 +1719,7 @@
       GenerateCachedNetworkParameters();
 
   std::string address_token = GetCryptoStream()->GetAddressToken(
-      cached_network_params.has_value() ? &cached_network_params.value()
-                                        : nullptr);
+      cached_network_params.has_value() ? &*cached_network_params : nullptr);
   if (address_token.empty()) {
     return false;
   }
diff --git a/quiche/quic/core/quic_session.h b/quiche/quic/core/quic_session.h
index 76600f5..1be2c30 100644
--- a/quiche/quic/core/quic_session.h
+++ b/quiche/quic/core/quic_session.h
@@ -617,7 +617,7 @@
   // TODO(wub): remove saving user-agent to QuicSession.
   void SetUserAgentId(std::string user_agent_id) {
     user_agent_id_ = std::move(user_agent_id);
-    connection()->OnUserAgentIdKnown(user_agent_id_.value());
+    connection()->OnUserAgentIdKnown(*user_agent_id_);
   }
 
   void SetSourceAddressTokenToSend(absl::string_view token) {
diff --git a/quiche/quic/core/quic_udp_socket.cc b/quiche/quic/core/quic_udp_socket.cc
index 8e35a2c..c114985 100644
--- a/quiche/quic/core/quic_udp_socket.cc
+++ b/quiche/quic/core/quic_udp_socket.cc
@@ -7,9 +7,10 @@
 #define __APPLE_USE_RFC_3542
 #endif  // defined(__APPLE__) && !defined(__APPLE_USE_RFC_3542)
 
+#include "quiche/quic/core/quic_udp_socket.h"
+
 #include "absl/base/optimization.h"
 #include "quiche/quic/core/io/socket.h"
-#include "quiche/quic/core/quic_udp_socket.h"
 #include "quiche/quic/platform/api/quic_bug_tracker.h"
 #include "quiche/quic/platform/api/quic_flag_utils.h"
 
@@ -96,16 +97,16 @@
   }
 
 #if !defined(_WIN32)
-  SetGoogleSocketOptions(socket.value());
+  SetGoogleSocketOptions(*socket);
 #endif
 
-  if (!SetupSocket(socket.value(), address_family, receive_buffer_size,
+  if (!SetupSocket(*socket, address_family, receive_buffer_size,
                    send_buffer_size, ipv6_only)) {
-    Destroy(socket.value());
+    Destroy(*socket);
     return kQuicInvalidSocketFd;
   }
 
-  return socket.value();
+  return *socket;
 }
 
 void QuicUdpSocketApi::Destroy(QuicUdpSocketFd fd) {
diff --git a/quiche/quic/core/tls_client_handshaker.cc b/quiche/quic/core/tls_client_handshaker.cc
index f15e932..0a9a7d2 100644
--- a/quiche/quic/core/tls_client_handshaker.cc
+++ b/quiche/quic/core/tls_client_handshaker.cc
@@ -236,12 +236,12 @@
   params.perspective = Perspective::IS_CLIENT;
   params.legacy_version_information =
       TransportParameters::LegacyVersionInformation();
-  params.legacy_version_information.value().version =
+  params.legacy_version_information->version =
       CreateQuicVersionLabel(session()->supported_versions().front());
   params.version_information = TransportParameters::VersionInformation();
   const QuicVersionLabel version = CreateQuicVersionLabel(session()->version());
-  params.version_information.value().chosen_version = version;
-  params.version_information.value().other_versions.push_back(version);
+  params.version_information->chosen_version = version;
+  params.version_information->other_versions.push_back(version);
 
   if (!handshaker_delegate()->FillTransportParameters(&params)) {
     return false;
@@ -282,15 +282,14 @@
       *received_transport_params_);
 
   if (received_transport_params_->legacy_version_information.has_value()) {
-    if (received_transport_params_->legacy_version_information.value()
-            .version !=
+    if (received_transport_params_->legacy_version_information->version !=
         CreateQuicVersionLabel(session()->connection()->version())) {
       *error_details = "Version mismatch detected";
       return false;
     }
     if (CryptoUtils::ValidateServerHelloVersions(
-            received_transport_params_->legacy_version_information.value()
-                .supported_versions,
+            received_transport_params_->legacy_version_information
+                ->supported_versions,
             session()->connection()->server_supported_versions(),
             error_details) != QUIC_NO_ERROR) {
       QUICHE_DCHECK(!error_details->empty());
@@ -299,15 +298,13 @@
   }
   if (received_transport_params_->version_information.has_value()) {
     if (!CryptoUtils::ValidateChosenVersion(
-            received_transport_params_->version_information.value()
-                .chosen_version,
+            received_transport_params_->version_information->chosen_version,
             session()->version(), error_details)) {
       QUICHE_DCHECK(!error_details->empty());
       return false;
     }
     if (!CryptoUtils::CryptoUtils::ValidateServerVersions(
-            received_transport_params_->version_information.value()
-                .other_versions,
+            received_transport_params_->version_information->other_versions,
             session()->version(),
             session()->client_original_supported_versions(), error_details)) {
       QUICHE_DCHECK(!error_details->empty());
@@ -559,12 +556,11 @@
   SSL_get0_peer_application_settings(ssl(), &alps_data, &alps_length);
   if (alps_length > 0) {
     auto error = session()->OnAlpsData(alps_data, alps_length);
-    if (error) {
+    if (error.has_value()) {
       // Calling CloseConnection() is safe even in case OnAlpsData() has
       // already closed the connection.
-      CloseConnection(
-          QUIC_HANDSHAKE_FAILED,
-          absl::StrCat("Error processing ALPS data: ", error.value()));
+      CloseConnection(QUIC_HANDSHAKE_FAILED,
+                      absl::StrCat("Error processing ALPS data: ", *error));
       return;
     }
   }
diff --git a/quiche/quic/core/tls_server_handshaker.cc b/quiche/quic/core/tls_server_handshaker.cc
index 8407bc6..5a8cb92 100644
--- a/quiche/quic/core/tls_server_handshaker.cc
+++ b/quiche/quic/core/tls_server_handshaker.cc
@@ -91,7 +91,7 @@
     // Return success to continue the handshake.
     return QUIC_SUCCESS;
   }
-  return handshaker_->select_cert_status().value();
+  return *handshaker_->select_cert_status();
 }
 
 QuicAsyncStatus TlsServerHandshaker::DefaultProofSourceHandle::ComputeSignature(
@@ -481,7 +481,7 @@
 
   if (client_params.legacy_version_information.has_value() &&
       CryptoUtils::ValidateClientHelloVersion(
-          client_params.legacy_version_information.value().version,
+          client_params.legacy_version_information->version,
           session()->connection()->version(), session()->supported_versions(),
           error_details) != QUIC_NO_ERROR) {
     return false;
@@ -489,7 +489,7 @@
 
   if (client_params.version_information.has_value() &&
       !CryptoUtils::ValidateChosenVersion(
-          client_params.version_information.value().chosen_version,
+          client_params.version_information->chosen_version,
           session()->version(), error_details)) {
     QUICHE_DCHECK(!error_details->empty());
     return false;
@@ -514,15 +514,15 @@
   server_params_.perspective = Perspective::IS_SERVER;
   server_params_.legacy_version_information =
       TransportParameters::LegacyVersionInformation();
-  server_params_.legacy_version_information.value().supported_versions =
+  server_params_.legacy_version_information->supported_versions =
       CreateQuicVersionLabelVector(session()->supported_versions());
-  server_params_.legacy_version_information.value().version =
+  server_params_.legacy_version_information->version =
       CreateQuicVersionLabel(session()->connection()->version());
   server_params_.version_information =
       TransportParameters::VersionInformation();
-  server_params_.version_information.value().chosen_version =
+  server_params_.version_information->chosen_version =
       CreateQuicVersionLabel(session()->version());
-  server_params_.version_information.value().other_versions =
+  server_params_.version_information->other_versions =
       CreateQuicVersionLabelVector(session()->supported_versions());
 
   if (!handshaker_delegate()->FillTransportParameters(&server_params_)) {
@@ -857,10 +857,9 @@
     // This is the second call, return the result directly.
     QUIC_DVLOG(1) << "EarlySelectCertCallback called to continue handshake, "
                      "returning directly. success:"
-                  << (select_cert_status_.value() == QUIC_SUCCESS);
-    return (select_cert_status_.value() == QUIC_SUCCESS)
-               ? ssl_select_cert_success
-               : ssl_select_cert_error;
+                  << (*select_cert_status_ == QUIC_SUCCESS);
+    return (*select_cert_status_ == QUIC_SUCCESS) ? ssl_select_cert_success
+                                                  : ssl_select_cert_error;
   }
 
   // This is the first call.
@@ -959,7 +958,7 @@
       set_transport_params_result.early_data_context,
       tls_connection_.ssl_config());
 
-  QUICHE_DCHECK_EQ(status, select_cert_status().value());
+  QUICHE_DCHECK_EQ(status, *select_cert_status());
 
   if (status == QUIC_PENDING) {
     set_expected_ssl_error(SSL_ERROR_PENDING_CERTIFICATE);
diff --git a/quiche/quic/load_balancer/load_balancer_config.cc b/quiche/quic/load_balancer/load_balancer_config.cc
index 89be497..5469a1a 100644
--- a/quiche/quic/load_balancer/load_balancer_config.cc
+++ b/quiche/quic/load_balancer/load_balancer_config.cc
@@ -177,7 +177,7 @@
   if (!key_.has_value()) {
     return false;
   }
-  AES_encrypt(plaintext, ciphertext, &key_.value());
+  AES_encrypt(plaintext, ciphertext, &*key_);
   return true;
 }
 
@@ -187,7 +187,7 @@
   if (!block_decrypt_key_.has_value()) {
     return false;
   }
-  AES_decrypt(ciphertext, plaintext, &block_decrypt_key_.value());
+  AES_decrypt(ciphertext, plaintext, &*block_decrypt_key_);
   return true;
 }
 
diff --git a/quiche/quic/load_balancer/load_balancer_decoder.h b/quiche/quic/load_balancer/load_balancer_decoder.h
index 5712b0f..f73f3a5 100644
--- a/quiche/quic/load_balancer/load_balancer_decoder.h
+++ b/quiche/quic/load_balancer/load_balancer_decoder.h
@@ -33,7 +33,7 @@
       return nullptr;
     }
 
-    return &config_[config_id].value();
+    return &*config_[config_id];
   }
 
   // Extract a server ID from |connection_id|. If there is no config for the
diff --git a/quiche/quic/masque/masque_server_session.cc b/quiche/quic/masque/masque_server_session.cc
index b2cb5f2..2cd15df 100644
--- a/quiche/quic/masque/masque_server_session.cc
+++ b/quiche/quic/masque/masque_server_session.cc
@@ -298,8 +298,7 @@
   hint.ai_protocol = IPPROTO_UDP;
 
   addrinfo* info_list = nullptr;
-  int result = getaddrinfo(host.value().c_str(), port.value().c_str(), &hint,
-                           &info_list);
+  int result = getaddrinfo(host->c_str(), port->c_str(), &hint, &info_list);
   if (result != 0 || info_list == nullptr) {
     QUIC_DLOG(ERROR) << "Failed to resolve " << authority << ": "
                      << gai_strerror(result);