-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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: Teams may have no associated main room on creation #33101
Conversation
🦋 Changeset detectedLatest commit: fd37df6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Looks like this PR is ready to merge! 🎉 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #33101 +/- ##
========================================
Coverage 59.38% 59.39%
========================================
Files 2547 2547
Lines 63255 63241 -14
Branches 14228 14231 +3
========================================
- Hits 37567 37559 -8
+ Misses 22978 22974 -4
+ Partials 2710 2708 -2
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Curious, the process will rollback and that's cool. But, is there a way to prevent the process from failing? I was thinking if the issue is the room name being invalid, maybe we can call a function that checks for that before attempting to create the team, wdyt?
@KevLehman I agree with you that we should add a naming validation for this. The issue is that this is not the only thing that may fail on Room creation, if you take a look at the Room.create() service, you can see that there are a lot of things that may fail, this fix aims to fix this specific edge case that causes a Team to be created with no room associated with it because of the naming (for direct api calls, from our UI it doesn't happen). |
No no yeah, that's great. I was thinking in having both, cause from your description it seems you already found a consistent way for this to happen. So, was thinking it's faster to cover that way earlier (before creating teams and doing more db calls) rather than waiting for the rollback to kick in 👀 @MarcosSpessatto @lucas-a-pelegrino wdyt? does it makes sense or do we think on these improvements on the "actual" fix on the next release? |
I think we can add the name validation early on in the method start, that would help but not resolve the whole issue... :/ A lot of things could still go wrong and a Team and TeamMember records could be created with no associated room. Even the TeamMember insertion could throw an unexpected error and fall into this edge case. |
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.
Please add a changeset to this PR
(btw we usually describe what's the error in the PR title, not the fix. Reference: https://developer.rocket.chat/docs/pull-requests-tags)
Co-authored-by: Kevin Aleman <[email protected]>
Co-authored-by: Guilherme Gazzo <[email protected]>
Proposed changes (including videos or screenshots)
This PR aims to temporary fix an issue where teams were created with no associated room due to some error occurring in the create room service.
Issue(s)
CORE-552
Steps to test or reproduce
To reproduce the error:
teams.create
with an invalid room name, i.e: team-with-invalid-char*With the fix in place:
teams.create
with an invalid room name, i.e: team-with-invalid-char*Further comments
After taking a good look on how the service is implemented, introducing the use of transactions which would be the better solution would take longer, and this fix is due to be included in the 6.12 release.
After the merge, I'll bring this issue up on our backend discussions so we can design a better flow for this service and maybe implement it in a way that makes using transactions doable, or even make it so the code is simpler and/or more reliable and such edge cases are handled properly.
Also, it would involve adding the database session on multiple methods as optional to be able to manage the transaction correctly. So a more quick and temporary solution was to invert the order the code executes, creating a
Team
and inserting theTeam Members
after aRoom
is successfully created.The behavior stays the same if converting a Room to a Team.