Skip to content

Conversation

eshitachandwani
Copy link
Member

@eshitachandwani eshitachandwani commented Sep 27, 2025

Fixes: #8607

RELEASE NOTES:

  • Fixes a bug where default port 443 was not being added to addresses without port being sent to proxy.
  • Adds a new environment variable GRPC_EXPERIMENTAL_RESOLVER_ADD_DEFAULT_PORT for adding a default port to addresses being sent to proxy which is set by default.

Copy link

codecov bot commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.03%. Comparing base (bb71072) to head (3d93bc1).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
.../resolver/delegatingresolver/delegatingresolver.go 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8613      +/-   ##
==========================================
+ Coverage   82.00%   82.03%   +0.03%     
==========================================
  Files         415      415              
  Lines       40697    40729      +32     
==========================================
+ Hits        33372    33414      +42     
+ Misses       5937     5925      -12     
- Partials     1388     1390       +2     
Files with missing lines Coverage Δ
internal/envconfig/envconfig.go 100.00% <ø> (ø)
.../resolver/delegatingresolver/delegatingresolver.go 87.95% <97.05%> (+1.52%) ⬆️

... and 25 files with indirect coverage changes

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

// AddDefaultPort is set if the resolver should add the default port when
// the target address doesn't contain a port. We will add the default port
// 443 for default scheme.
AddDefaultPort = boolFromEnv("GRPC_EXPERIMENTAL_RESOLVER_ADD_DEFAULT_PORT", true)
Copy link
Contributor

Choose a reason for hiding this comment

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

The name and the comment for this flag need to be more precise. Notably, this flag controls the addition of the default port only when all of the following conditions are met:

  1. A connect proxy is being used.
  2. Target resolution is disabled.
  3. DNS resolver is being used.

Comment on lines +114 to +117
addr, err := parseTarget(target.Endpoint())
if err != nil {
return nil, fmt.Errorf("delegating_resolver: invalid target address %q: %v", target.Endpoint(), err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should guard this call to parseTarget behind the feature flag since it can potentially lead to new/different failures after this PR is merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can have only one block guarded by the feature flag if we instead do the following:

addr := target.Endpoint()
if target.URL.Scheme == "dns" && !targetResolutionEnabled && envconfig.AddDefaultPort {
 addr, err = parseTarget(target.Endpoint(), defaultPort)
  if err != nil {
    // return some error
  }
}

This way we can use the parseTarget function from the dns resolver without any modifications.

// resolution should be handled by the proxy, not the client. Therefore, we
// bypass the target resolver and store the unresolved target address.
if target.URL.Scheme == "dns" && !targetResolutionEnabled {
addr := target.Endpoint()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we should be using the addr declared above, the one with the default hostname?

// verifies that the addresses returned by the delegating resolver include the
// proxy resolver's addresses, with the unresolved target URI as an attribute
// of the proxy address.
// TestDelegatingResolverWithProxy tests the creation of a delegating resolver
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of the test function doesn't match in the comment. It can be replaced with a shorter "Tests".

name string
target string
wantConnectAddress string
wantErrorSubstring string
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add another test param for the env variable and tests cases for the env variable being disabled?

t.Fatalf("Delegating resolver created, want error containing %q", test.wantErrorSubstring)
}
if !strings.Contains(err.Error(), test.wantErrorSubstring) {
t.Fatalf("Delegating resolver failed with error %q, want error containing %q", err.Error(), test.wantErrorSubstring)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We should used %v to format errors.

if !strings.Contains(err.Error(), test.wantErrorSubstring) {
t.Fatalf("Delegating resolver failed with error %q, want error containing %q", err.Error(), test.wantErrorSubstring)
}
// Expected error was found, so the test case for this part is done.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think the comment here is unnecessary, the return statement is self-explanatory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPS_PROXY support issues non-compliant CONNECT requests
2 participants