fix: correct user_id access logic (#4595)

fix: correct user_id access logic.
This commit is contained in:
dhlidongming 2024-11-14 18:31:02 +08:00 committed by GitHub
commit 0f5c31fd08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -185,7 +185,7 @@ class CustomComponent(BaseComponent):
@property
def user_id(self):
if hasattr(self, "_user_id"):
if hasattr(self, "_user_id") and self._user_id:
return self._user_id
return self.graph.user_id
@ -477,7 +477,7 @@ class CustomComponent(BaseComponent):
if not self.user_id:
msg = "Session is invalid"
raise ValueError(msg)
return await load_flow(user_id=str(self._user_id), flow_id=flow_id, tweaks=tweaks)
return await load_flow(user_id=str(self.user_id), flow_id=flow_id, tweaks=tweaks)
async def run_flow(
self,
@ -493,7 +493,7 @@ class CustomComponent(BaseComponent):
flow_id=flow_id,
flow_name=flow_name,
tweaks=tweaks,
user_id=str(self._user_id),
user_id=str(self.user_id),
run_id=self.graph.run_id,
)
@ -502,7 +502,7 @@ class CustomComponent(BaseComponent):
msg = "Session is invalid"
raise ValueError(msg)
try:
return list_flows(user_id=str(self._user_id))
return list_flows(user_id=str(self.user_id))
except Exception as e:
msg = f"Error listing flows: {e}"
raise ValueError(msg) from e