Skip to content

Commit f9b2ce1

Browse files
authored
fix: Improve variable decryption error handling (#6199)
* fix: Improve variable decryption error handling in DatabaseVariableService Add robust error handling for variable decryption, logging decryption failures and falling back to the original value for generic type variables * chore: Bump version to 1.1.4.post1 for langflow and 0.1.4.post1 for langflow-base
1 parent 141e673 commit f9b2ce1

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[project]
33
name = "langflow"
4-
version = "1.1.4"
4+
version = "1.1.4.post1"
55
description = "A Python package with a built-in web application"
66
requires-python = ">=3.10,<3.13"
77
license = "MIT"
@@ -19,7 +19,7 @@ maintainers = [
1919
]
2020
# Define your main dependencies here
2121
dependencies = [
22-
"langflow-base==0.1.4",
22+
"langflow-base==0.1.4.post1",
2323
"beautifulsoup4==4.12.3",
2424
"google-search-results>=2.4.1,<3.0.0",
2525
"google-api-python-client==2.154.0",

src/backend/base/langflow/services/variable/service.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ async def get_variable(
8383
async def get_all(self, user_id: UUID | str, session: AsyncSession) -> list[VariableRead]:
8484
stmt = select(Variable).where(Variable.user_id == user_id)
8585
variables = list((await session.exec(stmt)).all())
86-
# If the variable is of type 'Generic' we decrypt the value
86+
# For variables of type 'Generic', attempt to decrypt the value.
87+
# If decryption fails, assume the value is already plaintext.
8788
variables_read = []
8889
for variable in variables:
8990
value = None
9091
if variable.type == GENERIC_TYPE:
91-
value = auth_utils.decrypt_api_key(variable.value, settings_service=self.settings_service)
92-
92+
try:
93+
value = auth_utils.decrypt_api_key(variable.value, settings_service=self.settings_service)
94+
except Exception as e: # noqa: BLE001
95+
logger.debug(
96+
f"Decryption of {variable.type} failed for variable '{variable.name}': {e}. Assuming plaintext."
97+
)
98+
value = variable.value
9399
variable_read = VariableRead.model_validate(variable, from_attributes=True)
94100
variable_read.value = value
95101
variables_read.append(variable_read)

src/backend/base/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "langflow-base"
3-
version = "0.1.4"
3+
version = "0.1.4.post1"
44
description = "A Python package with a built-in web application"
55
requires-python = ">=3.10,<3.13"
66
license = "MIT"

uv.lock

Lines changed: 20 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)