-
Notifications
You must be signed in to change notification settings - Fork 1
add support for room version 12 #297
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
Conversation
Summary of ChangesHello @pitabwire, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates comprehensive support for Matrix Room Version 12, a significant update that introduces concepts like privileged creators and domainless room IDs. The changes involve a substantial overhaul of the room creation and upgrade workflows, ensuring that new room versions are correctly handled from initial setup to ongoing management. This includes refining permission checks, standardizing event generation, and updating core roomserver logic to align with the new protocol specifications. The overall aim is to enhance the platform's compatibility and feature set for the latest Matrix room standards. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds support for Matrix room version 12, introducing features like privileged creators and domainless room IDs. The changes are extensive and touch multiple parts of the codebase, including room creation, upgrades, and various permission checks.
I've identified several critical issues that could lead to panics due to missing nil checks when handling events, particularly the m.room.create event. These need to be addressed to ensure server stability. Additionally, there are some medium-severity issues related to incorrect error logging and a potential high-severity regression in federated room joining logic. Overall, the changes are in the right direction but require these fixes before merging.
| createEvent, err = r.DB.GetStateEvent(ctx, roomID, spec.MRoomCreate, "") | ||
| if err != nil { | ||
| return true, false, fmt.Errorf("r.DB.GetStateEvent: %w", err) | ||
| } | ||
| isPrivilegedCreator := gomatrixserverlib.MustGetRoomVersion(createEvent.Version()).PrivilegedCreators() && | ||
| slices.Contains(gomatrixserverlib.CreatorsFromCreateEvent(createEvent), string(senderID)) |
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.
r.DB.GetStateEvent can return a nil event with a nil error if the event is not found. The code only checks for a non-nil err but doesn't check if createEvent itself is nil. This will cause a panic on createEvent.Version() if the create event is not found. Please add a nil check for createEvent.
createEvent, err = r.DB.GetStateEvent(ctx, roomID, spec.MRoomCreate, "")
if err != nil {
return true, false, fmt.Errorf("r.DB.GetStateEvent: %w", err)
}
if createEvent == nil {
return true, false, fmt.Errorf("create event for room %s not found", roomID)
}
isPrivilegedCreator := gomatrixserverlib.MustGetRoomVersion(createEvent.Version()).PrivilegedCreators() &&
slices.Contains(gomatrixserverlib.CreatorsFromCreateEvent(createEvent), string(senderID))| return plc.UserLevel(senderID) >= plc.NotificationLevel(levelKey), nil | ||
| } | ||
| return true, nil | ||
| verImpl := gomatrixserverlib.MustGetRoomVersion(createEvent.Version()) |
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.
createEvent can be nil if no m.room.create event is found in the room state. Calling createEvent.Version() will cause a panic in this case. You should add a nil check for createEvent before using it.
if createEvent == nil {
// A room without a create event is invalid, but we should handle it gracefully.
return false, fmt.Errorf("room %s has no create event", rse.roomID)
}
verImpl := gomatrixserverlib.MustGetRoomVersion(createEvent.Version())| if err != nil { | ||
| return "", "", rsAPI.ErrInvalidID{Err: fmt.Errorf("room ID %q is invalid: %w", req.RoomIDOrAlias, err)} | ||
| } | ||
|
|
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.
The logic to add the room's domain to the list of servers to try for a federated join has been removed. This seems to be a regression for non-domainless room IDs. Without this, if a client tries to join a room like !foo:bar.com without providing an explicit server_name parameter, and this homeserver is not already in the room, the join will fail instead of trying to contact bar.com. Please consider re-adding this logic, perhaps with a check for domainless room IDs.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Pull Request Checklist
PR
or I have justified why this PR doesn't need tests
a sign off below using a legally identifiable name
or I have already signed off privately
Signed-off-by:
Your Name <$current_user_email>