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/updated useFindManyRecords for if messageChannels is null it returns null #7887

Closed

Conversation

krVatsal
Copy link

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 [] in packages/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 is null or undefined, 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 []
Copy link
Contributor

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 []
Copy link
Contributor

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 []
Copy link
Contributor

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

Copy link

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against ba3f33f

@bosiraphael
Copy link
Contributor

bosiraphael commented Oct 22, 2024

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.

@charlesBochet
Copy link
Member

/award 100

Copy link

oss-gg bot commented Oct 31, 2024

Awarding krVatsal: 100 points 🕹️ Well done! Check out your new contribution on oss.gg/krVatsal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Followup: ApolloError: useFindManyRecords for "messages" not supported
3 participants