[TT-14359] fix nested scopes for identity base field #7522
Merged
probelabs / Visor: performance
succeeded
Nov 10, 2025 in 6m 26s
✅ Check Passed (Warnings Found)
performance check passed. Found 1 warning, but fail_if condition was not met.
Details
📊 Summary
- Total Issues: 1
- Warning Issues: 1
🐛 Issues by Category
⚡ Performance (1)
⚠️ gateway/mw_jwt.go:1532 - The functiongetUserIDFromClaimperforms redundant lookups for JWT claims, which can impact performance on the request hot path. After an initial call togetClaimValuefails, the code proceeds to perform the same literal and nested lookups again to check for an empty value. This results in unnecessary CPU usage and memory allocations (fromstrings.Split) for every request where the identity claim is missing, empty, or of the wrong type.
Powered by Visor from Probelabs
💡 TIP: You can chat with Visor using /visor ask <your question>
Annotations
Check warning on line 1545 in gateway/mw_jwt.go
probelabs / Visor: performance
performance Issue
The function `getUserIDFromClaim` performs redundant lookups for JWT claims, which can impact performance on the request hot path. After an initial call to `getClaimValue` fails, the code proceeds to perform the same literal and nested lookups again to check for an empty value. This results in unnecessary CPU usage and memory allocations (from `strings.Split`) for every request where the identity claim is missing, empty, or of the wrong type.
Raw output
Refactor the logic to perform the claim lookup only once. The result of the single lookup should be inspected to determine if the claim is valid, empty, or not found, thus avoiding the repeated work. A potential approach is to perform the literal lookup, check the result, then perform the nested lookup if necessary, all within this function, instead of calling `getClaimValue` and then repeating its internal logic.
Loading