Skip to content

Use lowercase environment value during searching #831

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

rayluo
Copy link
Collaborator

@rayluo rayluo commented Jun 13, 2025

Context: The "environment" field in the token cache contains an authority's domain name, which is stored as lowercase in cache. We did that right. But we noticed that when performing a search in the token cache, we were not converting the "environment" field to lowercase. This is usually not a problem, because the domain name is typically in lowercase. And no customer reported any issue. However, recently when we are running Managed Identity test cases on Windows, we found out that the domain name placeholder that we use, turns out to be mixed case on Windows, such as "CPC-raylu-UB85C". This would cause cache miss when running the Managed Identity client on a Windows machine.

This PR improves the token cache search/match logic to always search environment by lowercase.

@rayluo rayluo requested a review from a team as a code owner June 13, 2025 18:45
query_with_lowercase_environment = {
# __add() canonicalized entry's environment value to lower case,
# so we do the same here.
k: v.lower() if k == "environment" else v

Choose a reason for hiding this comment

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

can this (v) be null?

# __add() canonicalized entry's environment value to lower case,
# so we do the same here.
k: v.lower() if k == "environment" else v
for k, v in query.items()

Choose a reason for hiding this comment

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

would be good to have some unit tests to assert retrieval with mixed-case query succeeds

@rayluo rayluo force-pushed the lowercase-instane-name branch from ad317f4 to a2a772e Compare June 14, 2025 02:27
@rayluo rayluo force-pushed the lowercase-instane-name branch from a2a772e to b1d8cd7 Compare June 14, 2025 02:35
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