Same machine as #2357
2020-12-10 15:43:21 +0000 - INFO: [b33798cc-5353-4fc4-a86f-186b609904ba] method=GET path=/b/bdb-0xe-ncp-0rd format=html controller=RoomsController action=show status=500 error='ActionView::Template::Error: undefined method `id' for nil:NilClass' duration=46.89 view=0.00 db=3.44 host=greenlight
2020-12-10 15:43:21 +0000 - FATAL: [b33798cc-5353-4fc4-a86f-186b609904ba]
2020-12-10 15:43:21 +0000 - FATAL: [b33798cc-5353-4fc4-a86f-186b609904ba] ActionView::Template::Error (undefined method `id' for nil:NilClass):
2020-12-10 15:43:21 +0000 - FATAL: [b33798cc-5353-4fc4-a86f-186b609904ba] 82: </div>
[b33798cc-5353-4fc4-a86f-186b609904ba] 83: </div>
[b33798cc-5353-4fc4-a86f-186b609904ba] 84:
[b33798cc-5353-4fc4-a86f-186b609904ba] 85: <% if current_user.ordered_rooms.length > 5 %>
[b33798cc-5353-4fc4-a86f-186b609904ba] 86: <div class="input-icon invite-link-input mb-3">
[b33798cc-5353-4fc4-a86f-186b609904ba] 87: <span class="input-icon-addon">
[b33798cc-5353-4fc4-a86f-186b609904ba] 88: <i class="fas fa-search"></i>
2020-12-10 15:43:21 +0000 - FATAL: [b33798cc-5353-4fc4-a86f-186b609904ba]
2020-12-10 15:43:21 +0000 - FATAL: [b33798cc-5353-4fc4-a86f-186b609904ba] app/models/user.rb:100:in `ordered_rooms'
[b33798cc-5353-4fc4-a86f-186b609904ba] app/views/rooms/show.html.erb:85:in `_app_views_rooms_show_html_erb__274100210107927512_47334747605440'
And user can't join.
As suggested in another issue, when querying:
User.where.not(id: User.joins(:roles).select(:id).distinct)
i get exactly the users which cause the errors.
So is my assumption right, they don't get the neccessary settings...?
We can reproduce the bug on our greenlight 2.7.11 instance for users who have no rights to create a new room.
Once we give these rights to the user at least once (and the user then has a home room?), the problem no longer occurs for this user.
It's happening here as well and it looks like the latest search feature is causing this problem.
Users without room creation rights can still access shared rooms, but it seems the search feature is depending on the ordered rooms list. This list always includes the home/main room, so it throws error 500 for users without one.
For the time being, I've restored access by editing room.rb.
If anyone's looking for a quick fix:
docker exec -it greenlight-v2 /bin/sh
vi app/models/user.rb
replace
# Returns a list of rooms ordered by last session (with nil rooms last)
def ordered_rooms
[main_room] + rooms.where.not(id: main_room.id).order(Arel.sql("last_session IS NULL, last_session desc"))
with
# Returns a list of rooms ordered by last session (with nil rooms last)
def ordered_rooms
if main_room.nil?
rooms.order(Arel.sql("last_session IS NULL, last_session desc"))
else
[main_room] + rooms.where.not(id: main_room.id).order(Arel.sql("last_session IS NULL, last_session desc"))
end
end
This is temporary and will be reverted by restarting greenlight with docker-compose.
Looks like I missed a use case when testing 馃う Will fix this for the next release (2.7.12)
Most helpful comment
Looks like I missed a use case when testing 馃う Will fix this for the next release (2.7.12)