'folder_id - UUID input should be a string, bytes or UUID object' when starting in backend mode with LANGFLOW_LOAD_FLOWS_PATH
Bug Description
I'm trying to start a pod in Kubernetes running the langflowai/langflow-backend:v1.1.1 image (also tested with langflowai/langflow:v1.1.1 image) with a flow that was exported from another langflow instance. I adjusted the LANGFLOW_LOAD_FLOWS_PATH to a path where I mounted a config map with the flow file. The pod starts but it keeps restarting because of the following error:
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/starlette/routing.py", line 693, in lifespan
async with self.lifespan_context(app) as maybe_state:
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
async with original_context(app) as maybe_original_state:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
async with original_context(app) as maybe_original_state:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
async with original_context(app) as maybe_original_state:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/langflow/main.py", line 108, in lifespan
await load_flows_from_directory()
File "/app/.venv/lib/python3.12/site-packages/langflow/initial_setup/setup.py", line 587, in load_flows_from_directory
flow = Flow.model_validate(flow, from_attributes=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/sqlmodel/main.py", line 760, in model_validate
return sqlmodel_validate(
^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/sqlmodel/_compat.py", line 313, in sqlmodel_validate
cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for Flow
folder_id
UUID input should be a string, bytes or UUID object [type=uuid_type, input_value=<coroutine object get_def...er_id at 0x7f02e0d0e4d0>, input_type=coroutine]
For further information visit https://errors.pydantic.dev/2.7/v/uuid_type
The flow file was attached in this issue. This is the Kubernetes deployment file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: langflow-teste-backend
namespace: langflow
spec:
selector:
matchLabels:
app: langflow-teste-backend
replicas: 1
template:
metadata:
labels:
app: langflow-teste-backend
spec:
containers:
- name: langflow-teste-backend
image: langflowai/langflow-backend:v1.1.1
command:
- /bin/bash
args:
- -c
- langflow run --backend-only --host 0.0.0.0 --port 7860
ports:
- containerPort: 7860
name: web
resources: {}
env:
- name: COLUMNS
value: "200"
- name: LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT
value: AZURE_OPENAI_API_DEPLOYMENT_NAME,AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME,AZURE_OPENAI_API_KEY,AZURE_OPENAI_API_VERSION,AZURE_OPENAI_API_ENDPOINT
- name: LANGFLOW_LOAD_FLOWS_PATH
value: /app/flows
envFrom:
- secretRef:
name: openai-config
volumeMounts:
- name: teste-flows
mountPath: /app/flows
- name: data-volume
mountPath: /app/data/
volumes:
- name: teste-flows
configMap:
name: teste-flows
- name: data-volume
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: langflow-teste-backend-service
namespace: langflow
spec:
selector:
app: langflow-teste-backend
ports:
- port: 80
targetPort: 7860
Reproduction
Steps to reproduce:
- Create namespace
langflowin the Kubernetes - Create the configmap as shown in the flow file section of this issue
- Deploy the backend using the YAML in the bug description
- Check the pod logs
Expected behavior
Backend started with the flow running.
Who can help?
No response
Operating System
Kubernetes
Langflow Version
1.1.1
Python Version
None
Screenshot
No response
Flow File
To create the config map:
kubectl create configmap teste-flows -n langflow --from-file=flow.json
The error you're encountering, "UUID input should be a string, bytes or UUID object," suggests that the folder_id field in your flow file is not being correctly interpreted as a UUID. This issue typically arises when the folder_id is not properly formatted or is being processed incorrectly.
Here are a few steps you can take to resolve this issue:
-
Check the Flow File: Ensure that the
folder_idin your flow file is a valid UUID string. It should be a properly formatted UUID, like123e4567-e89b-12d3-a456-426614174000. -
Flow File Structure: Verify that the flow file's structure is correct and that all fields are properly defined. The
folder_idshould be a string representing a UUID. -
Default Folder Handling: If the
folder_idis not specified or isNone, Langflow should automatically assign it to a default folder. Ensure that this logic is correctly implemented in your setup. You might want to check if the default folder exists and is correctly configured in your database. -
Environment Configuration: Double-check your Kubernetes configuration to ensure that the flow file is correctly mounted and accessible at the path specified by
LANGFLOW_LOAD_FLOWS_PATH. -
Debugging: Add logging or print statements in the code where the flow is loaded and validated to see the exact value of
folder_idbeing processed. This can help identify if the value is being altered or not set correctly.
By ensuring that the folder_id is a valid UUID and that your environment is correctly configured, you should be able to resolve this error. If the issue persists, consider reviewing the flow file and the logic that handles the folder_id assignment in the Langflow codebase.
To continue talking to Dosu, mention @dosu.
This is happening to me as well
Is it going to be fixed by? https://github.com/langflow-ai/langflow/pull/4891
Hi @amomra / @tssantos did you manage to solve it? I'm facing this issue too. The issue mentioned by @roman-shakudo is merged but no new version is been released yet and we are not sure if this will solve it.
This issue occurs because get_default_folder_id was not properly awaited. Since get_default_folder_id is an async def function, its invocation within the load_flows_from_directory function lacks the await keyword. As a result, folder_id becomes a coroutine object, which ultimately disrupts Pydantic’s validation process.
A temporary workaround is as follows:
async def load_flows_from_directory() -> None:
...
async with async_session_scope() as session:
...
for f in files:
...
if existing:
...
if existing.folder_id is None:
folder_id = await get_default_folder_id(session, user_id)
...
else:
...
folder_id = await get_default_folder_id(session, user_id)
...
I believe this issue has already been resolved in #4893.
@elolivier @HaloWorld Thanks for heads up. I did not test the fixes. I wait for a new version to be release. Till then I use LangFlow Runtime 1.1.0 and LangFlow Ide 1.1.1
Hi, @amomra. I'm Dosu, and I'm helping the langflow team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- The issue involves a Kubernetes pod restarting due to an invalid
folder_idUUID with thelangflowai/langflow-backend:v1.1.1image. - A missing
awaitin theget_default_folder_idfunction was identified as the root cause. - A workaround was provided, and the issue was resolved in pull request #4893.
- A new version release is awaited to confirm the fix by other users experiencing the same issue.
Next Steps:
- Please confirm if this issue is still relevant with the latest version of the langflow repository. If so, you can keep the discussion open by commenting here.
- If there is no further activity, this issue will be automatically closed in 7 days.
Thank you for your understanding and contribution!
I've tested and the issue was solved. Thanks!
Thank you for closing the issue, amomra! We appreciate your contribution to Langflow!