Skip to content
Snippets Groups Projects
Forked from ICS Control System Infrastructure / csentry
Source project has a limited visibility.
  • Benjamin Bertrand's avatar
    88f54ded
    Fix model update in admin interface · 88f54ded
    Benjamin Bertrand authored
    Following exception is raised when trying to update a network from
    flask-admin:
    sqlalchemy.exc.InvalidRequestError: Can't attach instance <User at 0x7f6f0e39ce10>;
    another instance with key (<class 'app.models.User'>, (1,), None) is already present in this session.
    
    1. If we remove the caching of the load_user method, the problem
    disappears.
    2. When updating a Network, this trigger an inventory update in
    before_flush which adds a task to the session. This is when the
    current_user is added to the session and the error raised.
    
    So the problem is linked to the user caching and flask-admin.
    
    The workaround is to remove the user object added by flask-admin to the
    session.
    
    JIRA INFRA-908 #action In Progress
    88f54ded
    History
    Fix model update in admin interface
    Benjamin Bertrand authored
    Following exception is raised when trying to update a network from
    flask-admin:
    sqlalchemy.exc.InvalidRequestError: Can't attach instance <User at 0x7f6f0e39ce10>;
    another instance with key (<class 'app.models.User'>, (1,), None) is already present in this session.
    
    1. If we remove the caching of the load_user method, the problem
    disappears.
    2. When updating a Network, this trigger an inventory update in
    before_flush which adds a task to the session. This is when the
    current_user is added to the session and the error raised.
    
    So the problem is linked to the user caching and flask-admin.
    
    The workaround is to remove the user object added by flask-admin to the
    session.
    
    JIRA INFRA-908 #action In Progress
Code owners
Assign users and groups as approvers for specific file changes. Learn more.