fix : unable to load env variables#10132
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughReplaces MCP composer feature flag, adds branch inputs to CI workflows, updates release orchestration, and ignores a new JSON file. Introduces Docker RUSTFLAGS, bumps versions in pyproject, updates Windows scripts. Adds an Alembic migration, multiple MCP Composer integrations, KB component refactors, Docling processing updates, assorted component metadata/labels, and various backend tweaks. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant FE as Frontend
participant API as Backend API
participant DB as DB
participant CS as MCP Composer Service
participant CMP as MCP Composer
Note over FE,API: Project auth settings update
U->>FE: Update project auth (e.g., OAuth)
FE->>API: PUT /projects/{id} with auth_settings
API->>API: handle_auth_settings_update(...)
alt should_start_composer
API->>CS: get_or_start_mcp_composer(auth_config, project)
CS->>CMP: Start/configure project
CS-->>API: OK/URL
else should_stop_composer
API->>CS: stop(project)
CS-->>API: Stopped
end
API->>DB: Save encrypted auth_settings
API-->>FE: Updated project + composer flags
Note over FE,API: Using MCP over SSE
FE->>API: GET /projects/{id}/composer_url
API->>CS: get_project_composer_url(project)
CS-->>API: URL or error
API-->>FE: URL
FE-->>CMP: Connect SSE (resolved by OS-aware URL)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| # Here you would have logic to create and configure a SettingsService | ||
|
|
||
| # Try to load env file if not already loaded | ||
| self._load_env_vars() |
There was a problem hiding this comment.
I think this covers most use cases, but unfortunately I just realized that we allow users to pass the env file path in as a CLI arg like uv run langflow run --env-file .my_custom_env_file_path.
The find_dotenv uses .env as a default, so that wouldn't work in this case.
It would be great if we could enforce that the SettingsService isn't initialized until after the env file is loaded, but I don't think we can do that quickly here.
We may have to go a different route of:
- Creating a hacky variable
do_initialize, which we pass to theget_settings_service(). That would then let us know we should re-initialize theSettingsServiceclass. So in this way, we ensure that even if the class is created prior to the load_dotenv, we're still going to re-init it after we've loaded in the env file.
There was a problem hiding this comment.
but my understanding is that , it still doesn't solve passing a custom env file in cli args.
|



Description
Issue was raised that, despite setting LANGFLOW_DATABASE_URL in .env file, it is defaulting to sqlite.
Root cause
Pydantic settings inside lfx/settings/base.py was instantiated even before env variables are loaded when starting langflow
Fix
Make sure env variables are loaded when calling settingservice
Testing
Before : #9795


After :
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores