-
Notifications
You must be signed in to change notification settings - Fork 149
fix: fatal server error when creating room with channel (#1343) #1379
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
base: enext
Are you sure you want to change the base?
fix: fatal server error when creating room with channel (#1343) #1379
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures that when creating a room with an associated chat channel, the newly created Channel instance is attached to the in-memory Room object before audit logging/serialization, preventing lazy-loading-related fatal errors. Sequence diagram for room creation with attached channelsequenceDiagram
participant Caller
participant Service as EventService
participant Room
participant ChannelModel as Channel
participant Serializer as RoomConfigSerializer
participant AuditLogModel as AuditLog
Caller->>Service: _create_room(data, with_channel=True, permission_preset, creator)
Service->>Room: create Room instance
activate Room
Room-->>Service: room
deactivate Room
alt with_channel is True
Service->>ChannelModel: objects.create(event_id=room.event_id, room=room)
activate ChannelModel
ChannelModel-->>Service: channel
deactivate ChannelModel
Service->>Room: set channel on room (room.channel = channel)
end
Service->>Serializer: RoomConfigSerializer(room)
activate Serializer
Serializer-->>Service: serialized room data (includes channel id)
deactivate Serializer
Service->>AuditLogModel: objects.create(event_id=room.event_id, data=serialized room data)
activate AuditLogModel
AuditLogModel-->>Service: audit_log
deactivate AuditLogModel
Service-->>Caller: room
Class diagram for Room, Channel, AuditLog and RoomConfigSerializerclassDiagram
class Room {
int id
int event_id
Channel channel
}
class Channel {
int id
int event_id
Room room
}
class AuditLog {
int id
int event_id
string data
datetime created_at
}
class RoomConfigSerializer {
Room instance
dict data
RoomConfigSerializer(Room instance)
}
Room --> Channel : has_one
Channel --> Room : belongs_to
AuditLog --> Room : logs_changes_for
RoomConfigSerializer --> Room : serializes
RoomConfigSerializer ..> Channel : accesses_channel_via_room
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
mariobehling
left a comment
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 showcase functionality by providing screenshots.
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.
Pull request overview
This PR fixes a fatal server error that occurred when creating a room with a chat channel enabled. The issue was caused by Django's ORM lazy-loading behavior when accessing the room.channel relationship during audit log serialization within an async context.
Key Changes:
- Explicitly assigns the newly created channel object to
room.channelin memory after channel creation - Ensures
RoomConfigSerializercan access the channel without triggering additional database queries
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9af4f31 to
59ca26d
Compare
|
@mariobehling Thanks for the review.
Since I am working in a cloud-based environment (Codespaces), I am currently blocked by a WebSocket restriction (Error 1006) which prevents the video frontend from rendering fully to capture a screenshot.
|
Description
Fixed a "Fatal Server Error" that occurred when creating a new room with a chat channel (e.g., "Chat" or "BigBlueButton" modules enabled).
The issue was caused because
RoomConfigSerializerattempted to access theroom.channelrelationship inside theAuditLogcreation step. Since thechannelobject was created but not manually attached to theroominstance in memory, the serializer triggered a lazy database lookup inside thesync_to_asynccontext, which likely failed or caused a race condition.Issues
Closes #1343
Fix
channelobject toroom.channelin memory before calling the serializer.RoomConfigSerializer(room).datacan serialize the channel ID without triggering additional database queries or failing.Type of Change
Summary by Sourcery
Bug Fixes: