Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve variable decryption error handling and version bump #6198

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[project]
name = "langflow"
version = "1.1.4"
version = "1.1.4.post1"
description = "A Python package with a built-in web application"
requires-python = ">=3.10,<3.13"
license = "MIT"
Expand All @@ -19,7 +19,7 @@ maintainers = [
]
# Define your main dependencies here
dependencies = [
"langflow-base==0.1.4",
"langflow-base==0.1.4.post1",
"beautifulsoup4==4.12.3",
"google-search-results>=2.4.1,<3.0.0",
"google-api-python-client==2.154.0",
Expand Down
12 changes: 9 additions & 3 deletions src/backend/base/langflow/services/variable/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ async def get_variable(
async def get_all(self, user_id: UUID | str, session: AsyncSession) -> list[VariableRead]:
stmt = select(Variable).where(Variable.user_id == user_id)
variables = list((await session.exec(stmt)).all())
# If the variable is of type 'Generic' we decrypt the value
# For variables of type 'Generic', attempt to decrypt the value.
# If decryption fails, assume the value is already plaintext.
variables_read = []
for variable in variables:
value = None
if variable.type == GENERIC_TYPE:
value = auth_utils.decrypt_api_key(variable.value, settings_service=self.settings_service)

try:
value = auth_utils.decrypt_api_key(variable.value, settings_service=self.settings_service)
except Exception as e: # noqa: BLE001
logger.debug(
f"Decryption of {variable.type} failed for variable '{variable.name}': {e}. Assuming plaintext."
)
value = variable.value
variable_read = VariableRead.model_validate(variable, from_attributes=True)
variable_read.value = value
variables_read.append(variable_read)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "langflow-base"
version = "0.1.4"
version = "0.1.4.post1"
description = "A Python package with a built-in web application"
requires-python = ">=3.10,<3.13"
license = "MIT"
Expand Down
Loading
Loading