Fix: client grants incorrectly matched when multiple grants share the same client_id + audience #1341
Merged
kushalshit27 merged 9 commits intomasterfrom Apr 8, 2026
Merged
Fix: client grants incorrectly matched when multiple grants share the same client_id + audience #1341kushalshit27 merged 9 commits intomasterfrom
kushalshit27 merged 9 commits intomasterfrom
Conversation
…th same client_id+audience
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1341 +/- ##
==========================================
+ Coverage 80.03% 80.06% +0.02%
==========================================
Files 152 152
Lines 6182 6196 +14
Branches 1282 1286 +4
==========================================
+ Hits 4948 4961 +13
Misses 701 701
- Partials 533 534 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kushalshit27
reviewed
Apr 1, 2026
kushalshit27
reviewed
Apr 6, 2026
kushalshit27
approved these changes
Apr 7, 2026
|
Hi @kushalshit27 - Can you advise when this fix will be merged and in what version? |
Contributor
|
Hi, @karlm-v2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Changes
Root cause
The identifier set used to match local grants to their remote counterparts was missing
subject_typeas a distinguishing field:Before
When two grants share the same
client_id + audiencebut differ bysubject_type, the matching algorithm couldn't tell them apart and paired them based on iteration order, causing the wrong grant to be updated on every deploy.Fix
After
id- unambiguous match when grant ID is present[client_id, audience, subject_type]- correctly distinguishes grants with same client_id + audience but different subject_type[client_id, audience]- fallback for grants where subject_type is null, preserving backward compatibility📚 References
Closes #1329
Backward compatibility
No breaking changes. The
['client_id', 'audience']fallback preserves existing behavior for tenants not usingsubject_type. Only tenants with multiple grants sharing the sameclient_id + audienceare affected.🔬 Testing
Added a unit test reproducing the exact failure scenario - two grants with the same client_id + audience but reversed order relative to the API response.
Without the fix the test fails; with the fix both grants are matched and updated correctly.
📝 Checklist