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.
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
Add session id to audit log #85451
Add session id to audit log #85451
Changes from all commits
f638fc4
7393366
ce576d5
eb07214
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question/nit: how do you feel about returning
null
instead ofundefined
here? So that it's consistent withgetCurrentUser
,Session.get
and etc?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find
null
a cause of unintended bugs and behaviours and the distinctions between "not set" (undefined
) and "set but empty" (null
) to be rarely important.e.g.
null
can cause bugs when using optional parameters and default values since the default value will not be used.null
is also of type object which is weird and can cause bugs so I rarely use it.Having said that, I think in this case, we really are dealing with the "not set" scenario so I think
undefined
is correct.Why are you using
null
for the other methods?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR: We don't have any guidelines on that yet and even though I have a slightly stronger opinion on
getCurrentUser
andSession.get
as explained below, I don't have the same strong reasons to usenull
in this particular case except for consistency. Both would work for me and I trust your judgement here 👍I think that we historically treated
null
not asset but empty
, but more like an intentional absence of any object value, like the user or session objects are absent in a particular context, it's expected and intentional, and we explicitly manifest that withnull
. As a side benefit, when youreturn null;
you explicitly define an exit point, whereundefined
can be either intentional or not (e.g. forgottenreturn
statement).Regarding default and optional parameters, I'd say it's more about personal preference, I find the code that is explicit about using default and optional parameters a little bit easier to read and understand, and type system will prevent unintentional behavior in case parameter cannot be
null
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the definition makes sense* then. For object values use
null
, for primitives useundefined
. That also explains why null is of type object.* I'm using "sense" in the loosest meaning of the word here since most other programming languages have a single type the denote absence of a value and get by just fine 🤷♀️