Skip to content
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

fix: NPE when connectionCookie is undefined #13541

Merged
merged 3 commits into from
May 27, 2022
Merged

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented May 4, 2022

Fix NPE in RTS when the connectionCookie is undefined.

@vercel
Copy link

vercel bot commented May 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
appsmith ✅ Ready (Inspect) Visit Preview May 16, 2022 at 5:59AM (UTC)

@github-actions github-actions bot added the Bug Something isn't working label May 4, 2022
@github-actions
Copy link

github-actions bot commented May 4, 2022

Unable to find test scripts. Please add necessary tests to the PR.

log.error("Error authenticating", error);
}
return false;
if (connectionCookie == null || connectionCookie === "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== for the first check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the problem actually. If we use === for null, then undefined will go through. I want to check for null and undefined. It is recommended to use == for null-checks in Javascript, and === everywhere else. Like the smart option in eslint: https://eslint.org/docs/rules/eqeqeq.

Copy link
Contributor

@IAmAnubhavSaini IAmAnubhavSaini May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick check you can deploy against null, undefined and "" is !connectionCookie. This is okay as long as you are not expecting a 0 or false.


I rather have very boring and explicit code base, like connectionCookie === undefined || connectionCookie === null || connectionCookie === ""; it tells me exactly when we going to drop in the if block.

connectionCookie == null || connectionCookie === "" needs a context and cursorily looks like one = is missing.

Please make it explicit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharat87 This change is pending. For maintainability it is very important for code to be unsurprising and boring.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

app/rts/src/server.ts Show resolved Hide resolved
app/rts/src/server.ts Outdated Show resolved Hide resolved
app/rts/src/server.ts Outdated Show resolved Hide resolved
app/rts/src/server.ts Outdated Show resolved Hide resolved
@github-actions
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label May 23, 2022
@sharat87 sharat87 merged commit f3f580a into release May 27, 2022
@sharat87 sharat87 deleted the sharat87-patch-1 branch May 27, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants