# HG changeset patch # User Mads Kiilerich # Date 1545766272 -3600 # Node ID d22a7430999fdc23128c66d3e6b405a39c64eb98 # Parent be37a0b982e9294e862179213b3e7df3164e8f24 auth: change get_allowed_ips to be more resilient when operating on a cached default user Before, random changes to how things are fetched and cached across database sessions could cause get_allowed_ips to fail with: DetachedInstanceError: Instance is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3) Instead, just check for user_id, using same pattern as a bit later in same function. diff -r be37a0b982e9 -r d22a7430999f kallithea/lib/auth.py --- a/kallithea/lib/auth.py Tue Dec 25 20:31:12 2018 +0100 +++ b/kallithea/lib/auth.py Tue Dec 25 20:31:12 2018 +0100 @@ -686,8 +686,8 @@ _set = set() if inherit_from_default: - default_ips = UserIpMap.query().filter(UserIpMap.user == - User.get_default_user(cache=True)) + default_ips = UserIpMap.query().filter(UserIpMap.user_id == + User.get_default_user(cache=True).user_id) if cache: default_ips = default_ips.options(FromCache("sql_cache_short", "get_user_ips_default"))