Skip to content

Commit

Permalink
mobile: removing some PANIC calls from Enovy mobile (envoyproxy#34586)
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored Jun 10, 2024
1 parent ccd1bf9 commit 0c9301f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PlatformBridgeCertValidator : public CertValidator, Logger::Loggable<Logge
void updateDigestForSessionId(bssl::ScopedEVP_MD_CTX& /*md*/,
uint8_t* /*hash_buffer[EVP_MAX_MD_SIZE]*/,
unsigned /*hash_length*/) override {
PANIC("Should not be reached");
IS_ENVOY_BUG("Should not be reached");
}
absl::optional<uint32_t> daysUntilFirstCertExpires() const override { return absl::nullopt; }
Envoy::Ssl::CertificateDetailsPtr getCaCertInformation() const override { return nullptr; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ Http::FilterHeadersStatus PlatformBridgeFilter::FilterBase::onHeaders(Http::Head
default:
PANIC("invalid filter state: unsupported status for platform filters");
}

PANIC("not reached");
}

Http::FilterDataStatus PlatformBridgeFilter::FilterBase::onData(Buffer::Instance& data,
Expand Down Expand Up @@ -407,8 +405,6 @@ Http::FilterDataStatus PlatformBridgeFilter::FilterBase::onData(Buffer::Instance
default:
PANIC("invalid filter state: unsupported status for platform filters");
}

PANIC("not reached");
}

Http::FilterTrailersStatus PlatformBridgeFilter::FilterBase::onTrailers(Http::HeaderMap& trailers) {
Expand Down Expand Up @@ -484,8 +480,6 @@ Http::FilterTrailersStatus PlatformBridgeFilter::FilterBase::onTrailers(Http::He
default:
PANIC("invalid filter state: unsupported status for platform filters");
}

PANIC("not reached");
}

Http::FilterHeadersStatus PlatformBridgeFilter::decodeHeaders(Http::RequestHeaderMap& headers,
Expand Down
2 changes: 1 addition & 1 deletion mobile/library/common/http/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ void Client::sendData(envoy_stream_t stream, Buffer::InstancePtr buffer, bool en
}
}

void Client::sendMetadata(envoy_stream_t, envoy_headers) { PANIC("not implemented"); }
void Client::sendMetadata(envoy_stream_t, envoy_headers) { IS_ENVOY_BUG("not implemented"); }

void Client::sendTrailers(envoy_stream_t stream, RequestTrailerMapPtr trailers) {
ASSERT(dispatcher_.isThreadSafe());
Expand Down
5 changes: 2 additions & 3 deletions mobile/library/common/http/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ class Client : public Logger::Loggable<Logger::Id::http> {
Stream& getStream() override { return direct_stream_; }
Http1StreamEncoderOptionsOptRef http1StreamEncoderOptions() override { return absl::nullopt; }
void encode1xxHeaders(const ResponseHeaderMap&) override {
// TODO(goaway): implement?
PANIC("not implemented");
IS_ENVOY_BUG("Unexpected 100 continue"); // proxy_100_continue_ false by default.
}
bool streamErrorOnInvalidHttpMessage() const override { return false; }
void setRequestDecoder(RequestDecoder& /*decoder*/) override{};
Expand All @@ -171,7 +170,7 @@ class Client : public Logger::Loggable<Logger::Id::http> {
Http::ResponseTrailerMapConstSharedPtr,
StreamInfo::StreamInfo&) override {}

void encodeMetadata(const MetadataMapVector&) override { PANIC("not implemented"); }
void encodeMetadata(const MetadataMapVector&) override { IS_ENVOY_BUG("Unexpected metadata"); }

void onHasBufferedData();
void onBufferedDataDrained();
Expand Down
5 changes: 3 additions & 2 deletions mobile/test/common/http/client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ TEST_P(ClientTest, Encode100Continue) {
TestResponseHeaderMapImpl response_headers{{":status", "200"}};
// Death tests are not supported on iOS.
#ifndef TARGET_OS_IOS
EXPECT_DEATH(response_encoder_->encode1xxHeaders(response_headers), "panic: not implemented");
EXPECT_ENVOY_BUG(response_encoder_->encode1xxHeaders(response_headers),
"Unexpected 100 continue");
#endif
}

Expand Down Expand Up @@ -688,7 +689,7 @@ TEST_P(ClientTest, EncodeMetadata) {
metadata_map_vector.push_back(std::move(metadata_map_ptr));
// Death tests are not supported on iOS.
#ifndef TARGET_OS_IOS
EXPECT_DEATH(response_encoder_->encodeMetadata(metadata_map_vector), "panic: not implemented");
EXPECT_ENVOY_BUG(response_encoder_->encodeMetadata(metadata_map_vector), "Unexpected metadata");
#endif
}

Expand Down
1 change: 1 addition & 0 deletions mobile/test/common/integration/client_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void ClientIntegrationTest::trickleTest(bool final_chunk_has_data) {
upstream_connection_->waitForNewStream(*BaseIntegrationTest::dispatcher_, upstream_request_));
ASSERT_TRUE(upstream_request_->waitForEndStream(*BaseIntegrationTest::dispatcher_));

upstream_request_->encode1xxHeaders(Http::TestResponseHeaderMapImpl{{":status", "100"}});
upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"}}, false);
// This will be read immediately. on_data_ will kick off more chunks.
upstream_request_->encodeData(1, false);
Expand Down

0 comments on commit 0c9301f

Please sign in to comment.