浏览代码

fix: EndUser not bound to Session when plugin invokes callback (#25132)

tags/2.0.0-beta.1
Will 1 个月前
父节点
当前提交
804e599598
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7
    5
      api/core/plugin/backwards_invocation/app.py

+ 7
- 5
api/core/plugin/backwards_invocation/app.py 查看文件

@@ -2,6 +2,7 @@ from collections.abc import Generator, Mapping
from typing import Optional, Union

from sqlalchemy import select
from sqlalchemy.orm import Session

from controllers.service_api.wraps import create_or_update_end_user_for_user_id
from core.app.app_config.common.parameters_mapping import get_parameters_from_feature_dict
@@ -194,11 +195,12 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
"""
get the user by user id
"""
stmt = select(EndUser).where(EndUser.id == user_id)
user = db.session.scalar(stmt)
if not user:
stmt = select(Account).where(Account.id == user_id)
user = db.session.scalar(stmt)
with Session(db.engine, expire_on_commit=False) as session:
stmt = select(EndUser).where(EndUser.id == user_id)
user = session.scalar(stmt)
if not user:
stmt = select(Account).where(Account.id == user_id)
user = session.scalar(stmt)

if not user:
raise ValueError("user not found")

正在加载...
取消
保存