Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthParams.WithTenant should copy all AuthorityInfo values #364

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

chlowell
Copy link
Collaborator

@chlowell chlowell commented Dec 9, 2022

This fixes an obscure bug that hasn't shipped yet: a client configured to use a regional endpoint sends requests for non-default tenants to the non-regional endpoint. That is to say, the per-request WithTenantID() option negates the client's region configuration for that request.

This happens because AuthParams.WithTenant() must update authority URLs when the user specifies a new tenant. That entails constructing a new authority.Info, whose constructor doesn't set its Region field. AuthParams.WithTenant() thus effectively resets Region to its zero value, which means "no region".

In this PR I've made the simplest fix and added a test that should prevent this problem from sneaking back in as Info expands. Info perhaps deserves another look from a design perspective to prevent this kind of thing but I chose not to get into that here because any improvement could require a large refactoring which may not be worth the effort--I don't have another example of the current design introducing risk.

@chlowell chlowell added the bug Something isn't working label Dec 9, 2022
@sonarcloud
Copy link

sonarcloud bot commented Dec 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@chlowell chlowell merged commit ec8940f into dev Dec 12, 2022
@chlowell chlowell deleted the chlowell/withtenant branch December 12, 2022 22:25
@rayluo rayluo mentioned this pull request Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants