bot: check for any falsey value of user in cancelOrder - #647
Conversation
WalkthroughThe update refactors the Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Despite `user` having type `UserDocument | null`, there was case [1] of it being `undefined`, leading to error when reading `banned` property after merging [2]. So go back to using `!user` checks that also account for `undefined`, so function will exit early and not produce an error. [1] lnp2pBot#633 (comment) [2] lnp2pBot#633
509f57b to
8e0ebcd
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bot/commands.ts (1)
585-585: Validate early return branch and add tests
Theif (!user) return;guard cleanly exits if the user isn't found. Please add a test case simulating an undefined or nulluserto ensure this path behaves as expected.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bot/commands.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: ci_to_main
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
bot/commands.ts (1)
578-578: Replace explicit null check with falsy check
Usingif (!user)now covers bothnullandundefined, preventing the previous runtime error when accessinguser.banned.
|
Tested cooperative cancellation and it produced no error. Order status was set back to "ACTIVE" |
Because of successful testing, this PR is no longer marked as DRAFT. |
Despite
userhaving typeUserDocument | null, there was case [1] of it beingundefined, leading to error when readingbannedproperty after merging [2]. So go back to using!userchecks that also account forundefined, so function will exit early and not produce an error.[1] #633 (comment)
[2] #633
Summary by CodeRabbit