-
Notifications
You must be signed in to change notification settings - Fork 10k
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
throw an exception on id.get if session is not available #57902
base: main
Are you sure you want to change the base?
Conversation
Thanks for your PR, @iamkrillin. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
It looks like the unavailability of a session is already signalled by an empty |
The problem I was running into was two fold:
These two things combined lead to a scenario where things looked to be working, but were not working. When I was working on this PR I though it was better to throw an exception since that would make it very clear that things were not working, but returning null would also work Either of these would be preferable to eating a error, then returning a value IMO |
I'm not actually familiar with this type, but the current behavior certainly appears to be intentional. If we were going to move to a model where it throws, wouldn't it make more sense to just add a Similarly, it would have been easy to give each failed session its own guid, so I assume they were grouped together with the id |
That's a fair enough point, I did consider adding a throw into the catch in Load, I ultimately decided against it since Load is called in many places and I wanted my change to be as small as possible. |
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
I was hoping an expert would chime in, but I'm not sure there is one for this type. 😆 Barring that, I think I'd prefer to just set it to If you need more explicit error behavior in your app, do you have the option of either checking |
I changed my application to check IsAvailable before opening this pull request, but figured if this behavior impacted me, perhaps it is impacting others. My Application was checking for null before as an error condition so that makes me think at some point in the past perhaps this API returned null in that scenario. My application has been around since .net 3 and is being updated to .net core so it may have been long ago. |
Thanks for taking time to contribute! 😄
It certainly seems possible that the sentinel used to be In my personal opinion, the best way forward would be to update the doc comments to explain that |
Throw exception on id.get
Summary of the changes (Less than 80 chars)
Description
Throw an exception in DistributedSession.Id.Get if the session is not available