Skip to content

Fix WithEndpoints and WithEnpointsResolver to rebuild the transport connector#39

Open
davidmz wants to merge 1 commit intoyandex-cloud:v2from
davidmz:fix/with-endpoints-rebuild-connector
Open

Fix WithEndpoints and WithEnpointsResolver to rebuild the transport connector#39
davidmz wants to merge 1 commit intoyandex-cloud:v2from
davidmz:fix/with-endpoints-rebuild-connector

Conversation

@davidmz
Copy link

@davidmz davidmz commented Feb 9, 2026

WithEndpoints and WithEnpointsResolver replace sdk.endpointResolver but copy the old sdk.conn as-is. Since ConnectorImpl captures the EndpointsResolver at construction time, GetConnection continues to resolve endpoints through the original resolver, so the override is silently ignored.

Fix rebuilds the ConnectorImpl with the new resolver and the existing connection pool so that GetConnection uses the updated endpoint mapping.

 func (sdk *SDK) WithEndpoints(endpoints *endpoints.PrefixEndpointsResolver) *SDK {
 	return &SDK{
 		ctx:              sdk.ctx,
-		conn:             sdk.conn,
+		conn:             transport.NewConnector(endpoints, sdk.connPool),
 		endpointResolver: endpoints,
 		connPool:         sdk.connPool,
 		authenticator:    sdk.authenticator,
 	}
 }

The same fix was applied to WithEnpointsResolver.

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru.

Both methods created a new SDK instance but copied the old connector
(sdk.conn) as-is. Since ConnectorImpl captures the EndpointsResolver
at construction time, GetConnection continued using the old resolver,
silently ignoring the override.

Fix: create a new ConnectorImpl with the new resolver and the existing
connection pool, so GetConnection uses the updated endpoint mapping.
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