Skip to content

fix : unable to load env variables#10132

Closed
HimavarshaVS wants to merge 12 commits into
release-1.6.4from
fix-issue-9795
Closed

fix : unable to load env variables#10132
HimavarshaVS wants to merge 12 commits into
release-1.6.4from
fix-issue-9795

Conversation

@HimavarshaVS
Copy link
Copy Markdown
Collaborator

@HimavarshaVS HimavarshaVS commented Oct 6, 2025

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 :
image
image

Summary by CodeRabbit

  • New Features

    • Project pagination; config now exposes voice_mode_available.
    • MCP Composer: new env flag (disabled by default), per-project auth flow, per-user MCP server files.
    • File loader gains Docling/VLM pipelines and advanced dataframe/markdown outputs.
    • Exposed “Vector Store Connection” output; revamped Knowledge Base ingestion/retrieval.
    • Agent UI updates; Memory supports session_id.
  • Bug Fixes

    • Prevented conditional-router loops; normalized Chroma limit handling.
    • More robust NVIDIA init; removed default credential logs.
    • Migration resolves file name uniqueness conflicts.
  • Documentation

    • Updated default OpenAI model selections.
  • Chores

    • Version/dependency upgrades; CI/release branch inputs; Docker build flags.
    • Ignored member_servers.json; numerous clearer API key labels; removed deprecated components.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 6, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Replaces 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

Cohort / File(s) Summary
Environment & Config
.env.example, .gitignore, pyproject.toml
Rename MCP composer flag to LANGFLOW_MCP_COMPOSER_ENABLED (default false); ignore member_servers.json; extensive dependency/version updates and metadata changes.
CI/CD Workflows
.github/workflows/ci.yml, .github/workflows/docs_test.yml, .github/workflows/lint-py.yml, .github/workflows/release.yml
Add optional branch inputs and propagate ref; adjust release to use release_branch, local build outputs, expanded needs, and debug prints.
Dockerfiles
docker/build_and_push*.Dockerfile
Set RUSTFLAGS="--cfg reqwest_unstable" across images.
Windows scripts
scripts/windows/build_and_run.bat, scripts/windows/build_and_run.ps1
Switch to USE_ENV_FILE flag; reorder uv run to place --env-file before command.
Core runtime & Logging
src/backend/base/langflow/__main__.py
Refine LANGFLOW_LOG_LEVEL handling; fetch default superuser password via get_secret_value; stop echoing default credentials.
DB Migration
.../alembic/versions/d37bc4322900_...py
Drop single-column UNIQUE(name) on files; dialect-specific upgrade/downgrade with table recreation on SQLite and constraint ops on PostgreSQL.
Build/Graph API
api/build.py
Include conditionally_excluded_vertices in inactivated set; log cancellation at info level.
Auth helpers
api/v1/auth_helpers.py
New handle_auth_settings_update to merge, mask, encrypt auth settings; returns composer control flags.
MCP Composer Integration
api/v1/mcp_projects.py, api/v2/mcp.py, api/v2/files.py
Introduce composer-aware auth/access flows, composer lifecycle helpers, dynamic MCP filename handling/migration, SSE URL utilities, cache invalidation, and signature updates.
Projects API
api/v1/projects.py
Add optional pagination; auto-enable API key when appropriate; start/stop MCP Composer on auth changes and deletions.
Config schema
api/v1/schemas.py
Add voice_mode_available to ConfigResponse and mapping.
Data handling (core)
base/data/base_file.py, base/data/docling_utils.py, base/data/utils.py
Switch to orjson parsing; add DoclingDependencyError and refined dependency error reporting; reorder/deduplicate TEXT_FILE_TYPES.
Models/Providers
base/models/anthropic_constants.py, base/models/model_input_constants.py
Mark claude-3-sonnet-20240229 deprecated; set Groq provider inactive.
Constants & Visibility
base/constants.py, base/vectorstores/vector_store_connection_decorator.py
Narrow SKIPPED_COMPONENTS to LanguageModelComponent; expose Vector Store Connection output (hidden=False).
Agents & Logic
components/agents/agent.py, components/logic/conditional_router.py, components/agents/mcp_component.py, base/agents/events.py
Remove Groq and “Custom” path; adjust agent outputs; improve conditional router iteration/exclusion logic; cache guard in MCP tool update; remove "Input:" prefix in messages.
Knowledge Bases Refactor
components/knowledge_bases/__init__.py, components/knowledge_bases/ingestion.py, .../retrieval.py, components/data/__init__.py
Replace KBIngestion/KBRetrieval with KnowledgeIngestion/KnowledgeRetrieval; rename outputs/methods; add include_embeddings; update inputs/types and error behavior; remove old exports.
File component & Docling
components/data/file.py, components/docling/docling_inline.py, components/docling/docling_remote.py
Add pipeline (standard/vlm), OCR toggling, new advanced_dataframe/advanced_markdown outputs, helper methods, subprocess handling, updated remote API (v1, new payload).
Vector store & Data
components/chroma/chroma.py, components/datastax/...
Normalize limit to int/None in Chroma; adjust Astra components (lazy imports, metadata serialization to Document, UI labels, reset configs, Vectorize metadata/replacement).
MCP deactivated removal
components/deactivated/mcp_sse.py, components/deactivated/mcp_stdio.py
Remove deactivated MCP SSE/stdio components entirely.
Component replacements/meta
components/* (multiple)
Add replacement attributes to several components (e.g., DataOperations, RunFlow, EmbeddingModel, agents); adjust display_name strings for API keys/passwords across providers; remove prototypes export.
Chat IO tweaks
components/input_output/chat.py, components/input_output/chat_output.py
Remove color/icon inputs; simplify message properties; adjust clean_data resolution in convert_to_string.
Misc component changes
components/google/google_serper_api_core.py (removed), components/helpers/memory.py, components/helpers/output_parser.py, components/helpers/store_message.py, components/data/api_request.py, components/data/url.py, components/data/csv_to_data.py, components/data/json_to_data.py, components/logic/*
Remove Google Serper component; memory adds session_id config and retrieval slicing fix; add replacements; API request handles Data-wrapped bodies; URL loader skips None header values.
Docs presets
docs/docs/Integrations/*/*.json
Update default OpenAI model selections to gpt-4.1 in Cleanlab/Notion configs.

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)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested labels

bug, lgtm

Suggested reviewers

  • lucaseduoli
  • erichare

Pre-merge checks and finishing touches and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.63% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title explicitly references the primary bug fix of enabling environment variable loading and concisely summarizes the issue being addressed without extraneous details.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HimavarshaVS HimavarshaVS changed the base branch from main to release-1.6.4 October 6, 2025 17:08
@HimavarshaVS HimavarshaVS requested a review from HzaRashid October 6, 2025 17:28
Comment thread src/backend/base/langflow/services/settings/factory.py Outdated
# Here you would have logic to create and configure a SettingsService

# Try to load env file if not already loaded
self._load_env_vars()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the get_settings_service(). That would then let us know we should re-initialize the SettingsService class. 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but my understanding is that , it still doesn't solve passing a custom env file in cli args.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 6, 2025

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants