From 2e7a5cdd6745f37791e06b2a5d2edd5b450fb871 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 12 Dec 2024 12:13:38 -0300 Subject: [PATCH] fix: improve UUID handling in custom component variables (#5230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 (custom_component.py): fix user_id assignment to convert it to UUID type for consistency and correctness * [autofix.ci] apply automated fixes * 🐛 (custom_component.py): fix potential bug by checking if self.user_id is a string before converting it to UUID --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../base/langflow/custom/custom_component/custom_component.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/custom/custom_component/custom_component.py b/src/backend/base/langflow/custom/custom_component/custom_component.py index b51cc287ba61..ed3584693276 100644 --- a/src/backend/base/langflow/custom/custom_component/custom_component.py +++ b/src/backend/base/langflow/custom/custom_component/custom_component.py @@ -1,6 +1,7 @@ from __future__ import annotations import asyncio +import uuid from collections.abc import Callable, Sequence from pathlib import Path from typing import TYPE_CHECKING, Any, ClassVar @@ -439,7 +440,8 @@ async def variables(self, name: str, field: str): variable_service = get_variable_service() # Get service instance # Retrieve and decrypt the variable by name for the current user async with async_session_scope() as session: - user_id = self.user_id or "" + if isinstance(self.user_id, str): + user_id = uuid.UUID(self.user_id) return await variable_service.get_variable(user_id=user_id, name=name, field=field, session=session) async def list_key_names(self):