Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pitabwire
Copy link
Owner

Pull Request Checklist

Signed-off-by: Your Name <$current_user_email>

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Room Version 12 Support: Introduces full support for Matrix Room Version 12, including its new features like privileged creators and domainless room IDs.
  • Refactored Room Creation Logic: The room creation process has been significantly refactored to handle new room versions, including generating create events and PDUs upfront for domainless room IDs.
  • Privileged Creator Permissions: Implements a new isPrivilegedCreator check across various API endpoints (directory, membership, redaction) to grant elevated permissions to designated creators in rooms supporting this feature.
  • Enhanced Room Upgrade Process: The room upgrade mechanism has been updated to support Room Version 12, allowing for the specification of additional creators during an upgrade and correctly handling the creation of new room events and predecessor information.
  • Centralized Event Generation: New utility functions GenerateCreateContent and GeneratePDU have been added to centralize and standardize the creation of events, improving consistency and maintainability.
  • Dependency Updates: Updates several Go module dependencies to their latest versions, ensuring compatibility and incorporating recent improvements.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +159 to +164
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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)}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

pitabwire and others added 7 commits September 24, 2025 20:02
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>
@pitabwire pitabwire enabled auto-merge September 24, 2025 17:21
@pitabwire pitabwire merged commit f71e7c2 into main Sep 24, 2025
8 checks passed
@pitabwire pitabwire deleted the room-v12-fix branch September 24, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants