[Bug] SuggestedCacheExpiry can be in the past and results in System.ArgumentOutOfRangeException: The relative expiration value must be positive.
See original GitHub issueA customer reported this issue with their InMemory OBO cache.
full exception:
System.ArgumentOutOfRangeException: The relative expiration value must be positive. (Parameter 'AbsoluteExpirationRelativeToNow')
Actual value was -18869.20:47:50.7160847.
Could be that there was an old cache with an expired token, and the expiry computed by MSAL was done in an older version, the newer version of MSAL no longer computes the expiry for OBO tokens, so the cache doesn’t know how to process it. not sure, needs to be investigated. Have not been able to repro locally.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (9 by maintainers)
Top Results From Across the Web
The relative expiration value must be positive · Issue #1419 ...
moving from Id web 1.15 to 1.16, a few reports of the SuggestedCacheExpiry form MSAL being a negative value with the OBO token...
Read more >LazyCache prevent null items being added to cache
Your code throws to me an ArgumentOutOfRangeException: The relative expiration value must be positive. on the line that assigns the entry.
Read more >AbpMemoryCacheManager Error #5063 | Support Center
System.ArgumentOutOfRangeException: The relative expiration value must be positive. Parameter name: AbsoluteExpirationRelativeToNow. Actual ...
Read more >FIX: Expiration time issue when you insert items by using ...
Fixes an issue in which items that are inserted into the Cache object by using the "Cache.Insert" method expire much earlier or later...
Read more >Expiration - requests-cache 1.1.0 documentation
By default, cached responses will be stored indefinitely. There are a number of options for specifying how long to store responses, either with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @petrochuk - the “sequence contains no elements” is a different problem. The tracking issue for it is: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3130
I have a PR out of it and we’re going to hotfix MSAL, most likely in a day or two. I expect MSAL 4.41.1 to have the fix.
What’s possibly happening is that CalculateSuggestedCacheExpiry is called in the finally clause.
So if an exception occured (e.g. during serialization to Redis), we still try to compute the cache expiry, but we will have not added a tokens to the cache. We should check if we indeed added them?