[call_creds_util] Add debug checks for metadata accesses (#37822)

Fix https://github.com/grpc/grpc/issues/37701

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #37822

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37822 from yijiem:debug-check-metadata 67df0da89c
PiperOrigin-RevId: 680734161
pull/37786/head^2
Yijie Ma 4 months ago committed by Copybara-Service
parent daa793860c
commit 80b57c909b
  1. 3
      src/core/lib/security/credentials/call_creds_util.cc

@ -18,6 +18,7 @@
#include <string.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
@ -42,6 +43,7 @@ struct ServiceUrlAndMethod {
ServiceUrlAndMethod MakeServiceUrlAndMethod(
const ClientMetadataHandle& initial_metadata,
const grpc_call_credentials::GetRequestMetadataArgs* args) {
DCHECK(initial_metadata->get_pointer(HttpPathMetadata()) != nullptr);
auto service =
initial_metadata->get_pointer(HttpPathMetadata())->as_string_view();
auto last_slash = service.find_last_of('/');
@ -56,6 +58,7 @@ ServiceUrlAndMethod MakeServiceUrlAndMethod(
method_name = service.substr(last_slash + 1);
service = service.substr(0, last_slash);
}
DCHECK(initial_metadata->get_pointer(HttpAuthorityMetadata()) != nullptr);
auto host_and_port =
initial_metadata->get_pointer(HttpAuthorityMetadata())->as_string_view();
absl::string_view url_scheme = args->security_connector->url_scheme();

Loading…
Cancel
Save