Skip to content

fix(oauth): ensure iam credentials endpoint is consistent with universe domain - #16700

Open
scotthart wants to merge 1 commit into
googleapis:v3.14.xfrom
scotthart:oauth2_minimal_iam_ud_314x
Open

scotthart wants to merge 1 commit into
googleapis:v3.14.xfrom
scotthart:oauth2_minimal_iam_ud_314x

Conversation

@scotthart

Copy link
Copy Markdown
Member

No description provided.

@scotthart
scotthart requested a review from a team as a code owner November 21, 2026 01:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors MinimalIamCredentialsRestStub to handle potential errors when retrieving the universe domain. Specifically, IamCredentialsEndpoint and MakeRequestPath now return StatusOr<std::string>, and AllowedLocationsHelper has been updated to accept a relative path and construct the full path internally after validating the universe domain endpoint. Unit tests have been added to cover these failure scenarios. Feedback on the changes suggests passing the universe_domain parameter in IamCredentialsEndpoint by const& instead of by value to avoid unnecessary copies of StatusOr<std::string>, as it is not a sink parameter.

Comment on lines +39 to 43
StatusOr<std::string> IamCredentialsEndpoint(
StatusOr<std::string> universe_domain) {
if (!universe_domain) return std::move(universe_domain).status();
return absl::StrCat("https://iamcredentials.", *universe_domain);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The universe_domain parameter is not a sink parameter because its value is only read to construct the endpoint URL and is not stored or moved into another object on the happy path. Passing it by const& avoids unnecessary moves or copies of StatusOr<std::string> when the function is called.

StatusOr<std::string> IamCredentialsEndpoint(
    StatusOr<std::string> const& universe_domain) {
  if (!universe_domain) return universe_domain.status();
  return absl::StrCat("https://iamcredentials.", *universe_domain);
}
References
  1. Scrutinize copies of non-fundamental C++ types. Since universe_domain is not a sink parameter, passing it by const reference avoids unnecessary moves/copies on the happy path. (link)

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.61%. Comparing base (1c9bc35) to head (53e6a77).

Additional details and impacted files
@@             Coverage Diff             @@
##           v3.14.x   #16700      +/-   ##
===========================================
- Coverage    92.63%   92.61%   -0.02%     
===========================================
  Files         2271     2271              
  Lines       224833   224902      +69     
===========================================
+ Hits        208272   208293      +21     
- Misses       16561    16609      +48     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants