Skip to content

Commit a19b234

Browse files
committed
change some other error status
1 parent 2bdecb0 commit a19b234

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/core/credentials/call/external/aws_external_account_credentials.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void AwsExternalAccountCredentials::AwsFetchBody::RetrieveSigningKeys() {
293293
}
294294
if (role_name_.empty()) {
295295
AsyncFinish(
296-
GRPC_ERROR_CREATE("Missing role name when retrieving signing keys."));
296+
absl::UnauthenticatedError("Missing role name when retrieving signing keys."));
297297
return;
298298
}
299299
std::string url_with_role_name = absl::StrCat(creds_->url_, "/", role_name_);

src/core/credentials/call/external/external_account_credentials.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void ExternalAccountCredentials::ExternalFetchRequest::ExchangeToken(
185185
// Parse URI.
186186
absl::StatusOr<URI> uri = URI::Parse(options().token_url);
187187
if (!uri.ok()) {
188-
return FinishTokenFetch(GRPC_ERROR_CREATE(
188+
return FinishTokenFetch(absl::UnauthenticatedError(
189189
absl::StrFormat("Invalid token url: %s. Error: %s", options().token_url,
190190
uri.status().ToString())));
191191
}
@@ -289,15 +289,15 @@ void ExternalAccountCredentials::ExternalFetchRequest::
289289
}
290290
auto it = json->object().find("access_token");
291291
if (it == json->object().end() || it->second.type() != Json::Type::kString) {
292-
FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
292+
FinishTokenFetch(absl::UnauthenticatedError(absl::StrFormat(
293293
"Missing or invalid access_token in %s.", *response_body)));
294294
return;
295295
}
296296
absl::string_view access_token = it->second.string();
297297
absl::StatusOr<URI> uri =
298298
URI::Parse(options().service_account_impersonation_url);
299299
if (!uri.ok()) {
300-
FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
300+
FinishTokenFetch(absl::UnauthenticatedError(absl::StrFormat(
301301
"Invalid service account impersonation url: %s. Error: %s",
302302
options().service_account_impersonation_url, uri.status().ToString())));
303303
return;

src/core/credentials/call/external/file_external_account_credentials.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ void FileExternalAccountCredentials::FileFetchBody::ReadFile() {
5555
// request because it may have changed since the last request.
5656
auto content_slice = LoadFile(creds_->file_, /*add_null_terminator=*/false);
5757
if (!content_slice.ok()) {
58-
Finish(content_slice.status());
58+
Finish(absl::UnavailableError(content_slice.status().message()));
5959
return;
6060
}
6161
absl::string_view content = content_slice->as_string_view();
6262
if (creds_->format_type_ == "json") {
6363
auto content_json = JsonParse(content);
6464
if (!content_json.ok() || content_json->type() != Json::Type::kObject) {
65-
Finish(GRPC_ERROR_CREATE(
65+
Finish(absl::UnauthenticatedError(
6666
"The content of the file is not a valid json object."));
6767
return;
6868
}

test/core/credentials/call/call_credentials_test.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,8 +3204,7 @@ TEST_F(ExternalAccountCredentialsTest, FailureInvalidTokenUrl) {
32043204
HttpRequest::SetOverride(httpcli_get_should_not_be_called,
32053205
httpcli_post_should_not_be_called,
32063206
httpcli_put_should_not_be_called);
3207-
// TODO(roth): This should return UNAUTHENTICATED.
3208-
grpc_error_handle expected_error = absl::UnknownError(
3207+
grpc_error_handle expected_error = absl::UnauthenticatedError(
32093208
"error fetching oauth2 token: Invalid token url: "
32103209
"invalid_token_url. Error: INVALID_ARGUMENT: Could not parse "
32113210
"'scheme' from uri 'invalid_token_url'. Scheme not found.");
@@ -3243,8 +3242,7 @@ TEST_F(ExternalAccountCredentialsTest,
32433242
HttpRequest::SetOverride(httpcli_get_should_not_be_called,
32443243
external_account_creds_httpcli_post_success,
32453244
httpcli_put_should_not_be_called);
3246-
// TODO(roth): This should return UNAUTHENTICATED.
3247-
grpc_error_handle expected_error = absl::UnknownError(
3245+
grpc_error_handle expected_error = absl::UnauthenticatedError(
32483246
"error fetching oauth2 token: Invalid service account impersonation url: "
32493247
"invalid_service_account_impersonation_url. Error: INVALID_ARGUMENT: "
32503248
"Could not parse 'scheme' from uri "
@@ -3284,8 +3282,7 @@ TEST_F(ExternalAccountCredentialsTest,
32843282
httpcli_get_should_not_be_called,
32853283
external_account_creds_httpcli_post_failure_token_exchange_response_missing_access_token,
32863284
httpcli_put_should_not_be_called);
3287-
// TODO(roth): This should return UNAUTHENTICATED.
3288-
grpc_error_handle expected_error = absl::UnknownError(
3285+
grpc_error_handle expected_error = absl::UnauthenticatedError(
32893286
"error fetching oauth2 token: Missing or invalid access_token in "
32903287
"{\"not_access_token\":\"not_access_token\",\"expires_in\":3599, "
32913288
"\"token_type\":\"Bearer\"}.");
@@ -3607,8 +3604,7 @@ TEST_F(ExternalAccountCredentialsTest,
36073604
HttpRequest::SetOverride(httpcli_get_should_not_be_called,
36083605
httpcli_post_should_not_be_called,
36093606
httpcli_put_should_not_be_called);
3610-
// TODO(roth): This should return UNAVAILABLE.
3611-
grpc_error_handle expected_error = absl::InternalError(
3607+
grpc_error_handle expected_error = absl::UnavailableError(
36123608
"error fetching oauth2 token: Failed to load file: "
36133609
"non_exisiting_file due to error(fdopen): No such file or directory");
36143610
auto state = RequestMetadataState::NewInstance(expected_error, {});
@@ -3658,8 +3654,7 @@ TEST_F(ExternalAccountCredentialsTest,
36583654
HttpRequest::SetOverride(httpcli_get_should_not_be_called,
36593655
httpcli_post_should_not_be_called,
36603656
httpcli_put_should_not_be_called);
3661-
// TODO(roth): This should return UNAUTHENTICATED.
3662-
grpc_error_handle expected_error = absl::UnknownError(
3657+
grpc_error_handle expected_error = absl::UnauthenticatedError(
36633658
"error fetching oauth2 token: The content of the file is not a "
36643659
"valid json object.");
36653660
auto state = RequestMetadataState::NewInstance(expected_error, {});
@@ -4364,8 +4359,7 @@ TEST_F(ExternalAccountCredentialsTest,
43644359
ASSERT_TRUE(creds.ok()) << creds.status();
43654360
ASSERT_NE(*creds, nullptr);
43664361
EXPECT_EQ((*creds)->min_security_level(), GRPC_PRIVACY_AND_INTEGRITY);
4367-
// TODO(roth): This should return UNAUTHENTICATED.
4368-
grpc_error_handle expected_error = absl::UnknownError(
4362+
grpc_error_handle expected_error = absl::UnauthenticatedError(
43694363
"error fetching oauth2 token: "
43704364
"Missing role name when retrieving signing keys.");
43714365
auto state = RequestMetadataState::NewInstance(expected_error, {});

0 commit comments

Comments
 (0)