Skip to content

Commit 1b3e46d

Browse files
Atryasvishnyakov
andauthored
fix: properly load user_env when it is '{}' (#2224)
Co-authored-by: Aleksandr Vishniakov <[email protected]>
1 parent bc1aeaf commit 1b3e46d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

backend/chainlit/socket.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ async def resume_thread(session: WebsocketSession):
6666

6767

6868
def load_user_env(user_env):
69+
if user_env:
70+
user_env_dict = json.loads(user_env)
6971
# Check user env
7072
if config.project.user_env:
71-
# Check if requested user environment variables are provided
72-
if user_env:
73-
user_env = json.loads(user_env)
74-
for key in config.project.user_env:
75-
if key not in user_env:
76-
raise ConnectionRefusedError(
77-
"Missing user environment variable: " + key
78-
)
79-
else:
73+
if not user_env_dict:
8074
raise ConnectionRefusedError("Missing user environment variables")
81-
return user_env
75+
# Check if requested user environment variables are provided
76+
for key in config.project.user_env:
77+
if key not in user_env_dict:
78+
raise ConnectionRefusedError(
79+
"Missing user environment variable: " + key
80+
)
81+
return user_env_dict
8282

8383

8484
def _get_token_from_cookie(environ: WSGIEnvironment) -> Optional[str]:

0 commit comments

Comments
 (0)