MultipleResultsFound: Multiple rows were found when one or none was required
Sentry Issue: PYCROFT-3G
MultipleResultsFound: Multiple rows were found when one or none was required
(12 additional frame(s) were not displayed)
...
File "pycroft/lib/user.py", line 364, in move_in
room = get_room(building_id, level, room_number)
File "pycroft/lib/facilities.py", line 154, in get_room
).one_or_none(),
File "sqlalchemy/orm/query.py", line 2849, in one_or_none
return self._iter().one_or_none()
File "sqlalchemy/engine/result.py", line 1464, in one_or_none
return self._only_one_row(
File "sqlalchemy/engine/result.py", line 614, in _only_one_row
raise exc.MultipleResultsFound(
Reason:
finish_member_request()
https://github.com/agdsn/pycroft/blob/7f4a5b770a429aa28bb6989a498eb6b4c6cfd1d7/pycroft/lib/user.py#L1286-L1287
calls move_in()
https://github.com/agdsn/pycroft/blob/7f4a5b770a429aa28bb6989a498eb6b4c6cfd1d7/pycroft/lib/user.py#L364
calls get_room()
https://github.com/agdsn/pycroft/blob/7f4a5b770a429aa28bb6989a498eb6b4c6cfd1d7/pycroft/lib/facilities.py#L149-L155
There are two rooms with the same (building_id, level, number) – one is inhabited, the other is not.
We should
a) add a unique key constraint over (building_id, level, number)
b) fix the „finalize membership request“ process so that it can directly pass a room to move_in instead of indirectly giving a (buiding_id, level, number) triple