Skip to content

fix(ConfigurableMessageHandler): Fix quota header on retry#3151

Merged
robertvoinescu-work merged 1 commit intogoogleapis:mainfrom
robertvoinescu-work:fix/configurableMessageHandler
Apr 22, 2026
Merged

fix(ConfigurableMessageHandler): Fix quota header on retry#3151
robertvoinescu-work merged 1 commit intogoogleapis:mainfrom
robertvoinescu-work:fix/configurableMessageHandler

Conversation

@robertvoinescu-work
Copy link
Copy Markdown
Contributor

b/414979515

@robertvoinescu-work robertvoinescu-work requested a review from a team as a code owner April 14, 2026 21:35
Copy link
Copy Markdown

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

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 modifies the ConfigurableMessageHandler to ensure that the quota project header is removed from the request before a retry is attempted. This allows the header to be re-applied fresh for each retry attempt. There are no review comments to evaluate, and I have no additional feedback to provide.

@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch 4 times, most recently from 7cf1f4c to afd6c72 Compare April 14, 2026 23:31
@robertvoinescu-work robertvoinescu-work changed the title fix(ConfigurableMessageHandler): Clear quota project on retry fix(ConfigurableMessageHandler): Only validate quota project header on first attempt Apr 14, 2026
@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch 5 times, most recently from bb4ba17 to c699f2d Compare April 15, 2026 00:15
@robertvoinescu-work robertvoinescu-work changed the title fix(ConfigurableMessageHandler): Only validate quota project header on first attempt fix(ConfigurableMessageHandler): Fix quota header on retry Apr 15, 2026
Comment thread Src/Support/Google.Apis.Auth/OAuth2/AccessTokenWithHeaders.cs Outdated
@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch from c699f2d to 96ad649 Compare April 15, 2026 16:14
Copy link
Copy Markdown
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

I have an alternative proposal that I believe it's both flexible and future proof.

Also, we don't go to the level of the type on the commit name prefixes. Here is fine to say just fix: ... without more granularity.

Comment thread Src/Support/Google.Apis.Auth/OAuth2/AccessTokenWithHeaders.cs Outdated
Comment thread Src/Support/Google.Apis.Auth/OAuth2/AccessTokenWithHeaders.cs Outdated
@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch 2 times, most recently from 60f0954 to c794d4d Compare April 17, 2026 18:58
Copy link
Copy Markdown
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

The existing test for this is now failing, which is right. I think we need to add more tests for AccessTOkenWithHeaders and can remove the failing test for the request.

requestHeaders.Add(header.Key, header.Value);
// In the case it's a single value header we will not add it if already present, just validate we match
// what's already there.
if (IsSingleValueHeader(header.Key) && requestHeaders.TryGetValues(header.Key, out var existingValue))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tiny nit:

Suggested change
if (IsSingleValueHeader(header.Key) && requestHeaders.TryGetValues(header.Key, out var existingValue))
if (IsSingleValueHeader(header.Key) && requestHeaders.TryGetValues(header.Key, out var existingValues))


void ValidateMatch(string key, IEnumerable<string> existing, IEnumerable<string> incoming)
{
if (!existing.SequenceEqual(incoming))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As this check is being done for single value headers only I think we can skip the part where we compare collections. If either side has more than one value, we can throw. And if both sides have a single value each we only throw if those values are different.

The exception message needs to read something like "Only a single value may be specified for {key}".

@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch 3 times, most recently from 604cca1 to b751429 Compare April 20, 2026 17:25
@robertvoinescu-work robertvoinescu-work force-pushed the fix/configurableMessageHandler branch from b751429 to b3df97f Compare April 21, 2026 17:00
@robertvoinescu-work robertvoinescu-work merged commit d50f5cb into googleapis:main Apr 22, 2026
5 checks passed
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