feat: Add support for passing env vars to run command by edwinjosechittilappilly · Pull Request #10986 · langflow-ai/langflow (original) (raw)

@edwinjosechittilappilly

The run CLI command now accepts --env-var KEY=VALUE options to inject global variables into the graph context. Includes validation for variable format and unit tests to verify correct injection and error handling. Also improves script loading to register modules by script name for better inspection.

@edwinjosechittilappilly changed the titleAdd support for passing env vars to run command feat:Add support for passing env vars to run command

Dec 12, 2025

@autofix-ci

ogabrielluiz

@edwinjosechittilappilly

Updated environment variable loading logic to prioritize CLI-provided variables (request_variables in context) over OS environment variables for load_from_db fields. Added unit tests to verify correct precedence and fallback behavior.

@autofix-ci

@edwinjosechittilappilly

@autofix-ci

Copilot AI review requested due to automatic review settings

December 12, 2025 17:36

@edwinjosechittilappilly

@autofix-ci

@autofix-ci

@autofix-ci

@edwinjosechittilappilly

@autofix-ci

@autofix-ci

@autofix-ci

@edwinjosechittilappilly

Add a pytest fixture to configure structlog before tests to prevent AttributeError when mocking logger.configure. Update unit tests to patch the actual logger module using sys.modules, ensuring correct patching and avoiding issues with module references.

@edwinjosechittilappilly

@autofix-ci

@autofix-ci

@autofix-ci

Adam-Aghili

@Adam-Aghili Adam-Aghili changed the titlefeat:Add support for passing env vars to run command feat: Add support for passing env vars to run command

Dec 17, 2025

Wallgau pushed a commit that referenced this pull request

Dec 18, 2025

The run CLI command now accepts --env-var KEY=VALUE options to inject global variables into the graph context. Includes validation for variable format and unit tests to verify correct injection and error handling. Also improves script loading to register modules by script name for better inspection.

Updated environment variable loading logic to prioritize CLI-provided variables (request_variables in context) over OS environment variables for load_from_db fields. Added unit tests to verify correct precedence and fallback behavior.

Refactors the run CLI command to delegate execution logic to a new lfx.run.base module, improving separation of concerns and maintainability. Moves core run logic and error handling into lfx.run.base, introduces a RunError exception, and updates tests to target the new structure. Removes the --env-var option from the CLI and migrates related tests to the run module.

Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org

Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org

Moved the import of PydanticDeprecatedSince20 to group it with other pydantic imports, improving code organization.

Add a pytest fixture to configure structlog before tests to prevent AttributeError when mocking logger.configure. Update unit tests to patch the actual logger module using sys.modules, ensuring correct patching and avoiding issues with module references.


Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida gabriel@langflow.org

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})