-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Bug Description
Description
When running Langflow (v1.7.1) in a Kubernetes environment using langflow-runtime k8s helm charts, Global Variables defined via the LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT environment variable are not accessible via the API after container startup.
Requests made using a valid LANGFLOW_API_KEY fail because the variables are not found in the database. The variables only become available/active after a Superuser explicitly logs in via Swagger docs (or the UI if enabled). Once this login event occurs, subsequent API Key requests work correctly.
This behavior blocks "headless" or backend-only deployments where no human interaction with the UI is expected.
System Information
- Langflow Version: 1.7.1
- Deployment Method: Helm Chart (
langflow-runtime) on Kubernetes - Python Version: 3.12
- Database: SQLite (Ephemeral/
emptyDir- database is fresh on every pod start)
Environment Configuration
The pod is configured with the following environment variables:
LANGFLOW_AUTO_LOGIN="false"
LANGFLOW_API_KEY="sk-..." # Valid API Key
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT="AZURE_API_KEY"
AZURE_API_KEY="<actual_value>"Workaround
I am currently forcing a "wake up" of the variables by adding a postStart hook or a sidecar script that waits for the service to be ready and then performs a curl POST /api/v1/login request. This is not ideal for production.
Reproduction
Steps to Reproduce
- Deploy Langflow with an ephemeral SQLite database (fresh state).
- Configure
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENTto sync a variable (e.g.,AZURE_API_KEY). - Wait for the pod to reach
Runningstate. - Attempt 1 (Fail): Immediately try to list variables using the API Key:
Result: Returns
curl -X GET "http://<host>:7860/api/v1/variables" \ -H "x-api-key: <your-api-key>"
[](Empty list). Flows using these variables fail. - Intervention: Perform a login request via Swagger or curl using Superuser credentials:
curl -X POST "http://<host>:7860/api/v1/login" \ -d "username=<user>&password=<pass>" ...
- Attempt 2 (Success): Retry the API Key request from Step 4.
Result: Returns[{"name": "AZURE_API_KEY", ...}]. Flows now work.
Expected behavior
Expected Behavior
Variables defined in LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT should be synchronized from the OS environment to the database during the application startup process, ensuring they are available for API-based execution immediately, without requiring a User Session or Login event.
Actual Behavior
The variables are not synchronized on startup. It appears the synchronization logic is triggered only upon the first successful user authentication/login event. Since the database is fresh (ephemeral), the variables table is empty until this event triggers.
Who can help?
Operating System
Docker image langflow/langflow:1.7.1 running inside a k8s cluster (deployed using https://github.com/langflow-ai/langflow-helm-charts)
Langflow Version
1.7.1
Python Version
3.12
Screenshot
No response
Flow File
No response