Skip to content

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

Open
scotthart wants to merge 1 commit into
googleapis:mainfrom
scotthart:oauth2_minimal_iam_ud
Open

scotthart wants to merge 1 commit into
googleapis:mainfrom
scotthart:oauth2_minimal_iam_ud

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:30

@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 properly handle potential errors when retrieving the universe domain, updating IamCredentialsEndpoint and MakeRequestPath to return StatusOr<std::string> and adding corresponding unit tests for failure paths. A review comment suggests passing universe_domain by const& in IamCredentialsEndpoint to avoid unnecessary copies or moves of the StatusOr and its underlying string, which aligns with the repository's optimization guidelines.

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

Passing StatusOr<std::string> by value to IamCredentialsEndpoint causes unnecessary moves/copies of the underlying std::string when the function is called. Since absl::StrCat only reads the string, we can pass universe_domain by const& to avoid any overhead of moving or copying the StatusOr or its contained string.

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. Is it necessary to copy the data? Can we move the data instead? (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.76%. Comparing base (eb5ee8c) to head (f807c21).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16699      +/-   ##
==========================================
+ Coverage   92.74%   92.76%   +0.01%     
==========================================
  Files        2271     2271              
  Lines      227219   227288      +69     
==========================================
+ Hits       210734   210833      +99     
+ Misses      16485    16455      -30     

☔ 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.

1 participant