Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit 599f2ef

Browse files
Privacy Sandbox Teamcopybara-github
authored andcommitted
fix: Log entire request in case of private key fetch error
Change-Id: Ia00b320e4324e853b0e9d216d247ef88a5aae031 Bug: go/gads-staging-errors-04-24 GitOrigin-RevId: eea72db166a00f054b33d78de6af261fe2b1848b
1 parent f47657f commit 599f2ef

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/encryption/key_fetcher/private_key_fetcher.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ namespace privacy_sandbox::server_common {
5858
namespace {
5959

6060
constexpr std::string_view kKeyFetchFailMessage =
61-
"GetEncryptedPrivateKey call failed (key IDs: $0, status_code: $1)";
61+
"GetEncryptedPrivateKey call failed (request: $0, status_code: $1)";
6262

6363
absl::Status HandleFailure(
64-
const google::protobuf::RepeatedPtrField<std::string>& key_ids,
64+
const ListPrivateKeysRequest& request,
6565
google::scp::core::StatusCode status_code,
6666
privacy_sandbox::server_common::log::PSLogContext& log_context) noexcept {
67-
std::string key_ids_str = absl::StrJoin(key_ids, ", ");
68-
const std::string error = absl::Substitute(kKeyFetchFailMessage, key_ids_str,
67+
const std::string error = absl::Substitute(kKeyFetchFailMessage, request,
6968
GetErrorMessage(status_code));
7069
PS_LOG(ERROR, log_context) << error;
7170
return absl::UnavailableError(error);
@@ -160,17 +159,15 @@ absl::Status PrivateKeyFetcher::Refresh() noexcept ABSL_LOCKS_EXCLUDED(mutex_) {
160159
} else {
161160
KeyFetchResultCounter::IncrementPrivateKeyFetchAsyncFailureCount();
162161
KeyFetchResultCounter::SetNumPrivateKeysParsed(0);
163-
HandleFailure(request.key_ids(), result.status_code, log_context_)
164-
.IgnoreError();
162+
HandleFailure(request, result.status_code, log_context_).IgnoreError();
165163
}
166164
fetch_notify.Notify();
167165
};
168166
if (const absl::Status error = private_key_client_->ListPrivateKeys(
169167
request, std::move(list_priv_key_cb));
170168
!error.ok()) {
171-
auto error_message = absl::Substitute(
172-
kKeyFetchFailMessage, absl::StrJoin(request.key_ids(), ", "),
173-
error.message());
169+
auto error_message =
170+
absl::Substitute(kKeyFetchFailMessage, request, error.message());
174171
PS_LOG(ERROR, log_context_) << "ListPrivateKeys failed: " << error_message;
175172
return absl::Status(error.code(), error_message);
176173
}

0 commit comments

Comments
 (0)