-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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/updated useFindManyRecords for if messageChannels is null it returns null #7887
Conversation
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.
PR Summary
This PR adds a check for empty message channels in the canAccessMessageThread
method to address potential errors when processing message threads.
- Added
if(messageChannels.length===0) return []
inpackages/twenty-server/src/modules/messaging/common/query-hooks/message/can-access-message-thread.service.ts
- The new check prevents further processing when no message channels are found, potentially avoiding errors with empty arrays
- Consider handling the case where
messageChannels
isnull
orundefined
, not just empty - The return value
[]
may not be appropriate for this method, as it's not clear how this affects the access control logic - Review the overall error handling strategy in this method to ensure consistent behavior across different scenarios
1 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -54,6 +54,7 @@ export class CanAccessMessageThreadService { | |||
'connectedAccount', | |||
); | |||
|
|||
if(messageChannels.length===0) return [] |
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.
style: Consider using return []
instead of return
@@ -54,6 +54,7 @@ export class CanAccessMessageThreadService { | |||
'connectedAccount', | |||
); | |||
|
|||
if(messageChannels.length===0) return [] |
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.
style: Add space after if
for consistency
@@ -54,6 +54,7 @@ export class CanAccessMessageThreadService { | |||
'connectedAccount', | |||
); | |||
|
|||
if(messageChannels.length===0) return [] |
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.
logic: This check should be placed earlier in the method, before using messageChannels
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
Hello @krVatsal, thank you for contributing :) Actually, I think we would prefer to throw an error here, because it shouldn't happen. Also, this won't fix the underlying bug, I still have to investigate to find what is causing this behavior. |
/award 100 |
Awarding krVatsal: 100 points 🕹️ Well done! Check out your new contribution on oss.gg/krVatsal |
Fixed #7830
Include a check of
if(messageChannels.length===0) return []
that if the messageChannels is coming as null then just return and don't perform any further operation, it will allow to go forward only if messageChannels.length>0