Skip to content

Conversation

@erichare
Copy link
Collaborator

@erichare erichare commented Nov 6, 2025

This pull request makes a minor update to the Document Q&A.json starter project by changing the code_hash in the metadata. This likely reflects a new build or version of the project, but no functional or structural changes are introduced.

Summary by CodeRabbit

  • New Features

    • Enhanced File component output handling with improved tool mode configuration across single and multi-file processing scenarios.
  • Updates

    • Updated starter project configurations for Document Q&A, Portfolio Website Code Generator, Text Sentiment Analysis, and Vector Store RAG.
    • Updated News Aggregator dependency version.
  • Tests

    • Added test coverage for File component output behavior validation.

@erichare erichare changed the title fix: Support tool mode in dynamic outputs fix: Support tool mode in File Component properly Nov 6, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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

The changes add a tool_mode=True parameter to Output declarations throughout the File component implementation and related starter project configurations. This includes updates to the File component in src/lfx/src/lfx/components/data/file.py, corresponding changes in five starter project JSON templates, and a new unit test validating the tool_mode behavior across different file processing scenarios.

Changes

Cohort / File(s) Summary
Starter Projects Update
src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json, News Aggregator.json, Portfolio Website Code Generator.json, Text Sentiment Analysis.json, Vector Store RAG.json
Updated code hashes in File component metadata and modified Output declarations to include tool_mode=True for Raw Content output. News Aggregator.json also updated google dependency from 0.6.15 to 0.8.5. Code string serialization formatting adjusted in JSON structure.
File Component Implementation
src/lfx/src/lfx/components/data/file.py
Added tool_mode=True parameter to Output constructor calls across multiple scenarios: Raw Content output (single file), Structured Content outputs for dataframe and JSON, advanced-mode outputs (Markdown, File Path), multi-file path outputs, and related File Path outputs.
Unit Test Addition
src/backend/tests/unit/components/data/test_file_component.py
Added new test method test_dynamic_outputs_have_tool_mode_enabled to validate that update_outputs consistently sets tool_mode=True across single files, multiple files, and advanced_mode toggle scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The changes follow a consistent, repetitive pattern of adding tool_mode=True to Output declarations across multiple call sites
  • Starter project JSON updates are largely metadata/version bumps with minor serialization formatting changes
  • The new test method mirrors existing patterns without introducing complex assertions or edge cases
  • Primary attention areas: verify that all Output usages have been consistently updated in the File component and confirm the test adequately covers the tool_mode propagation behavior

Possibly related PRs

Suggested labels

bug, size:M, lgtm

Suggested reviewers

  • edwinjosechittilappilly
  • rodrigosnader
  • ogabrielluiz

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (2 inconclusive)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❓ Inconclusive Test method test_dynamic_outputs_have_tool_mode_enabled was added but full implementation verification is inconclusive. Starter project JSON updates lack corresponding integration tests. Verify the test method contains proper assertions validating tool_mode=True across all Output declarations and add integration tests for updated starter projects.
Test Quality And Coverage ❓ Inconclusive Test covers main code paths with proper setup/cleanup and two-level assertions, but only validates attribute presence/value, not actual behavioral impact of tool_mode on system functionality. Add behavioral tests verifying tool_mode affects downstream behavior, test negative cases (tool_mode=False), and confirm propagation through component inheritance chain.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective of the PR: adding tool_mode support to the File Component across multiple starter projects and the core component implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Test File Naming And Structure ✅ Passed Test file follows correct naming convention with test_ prefix, proper directory structure, descriptive class and method names, and comprehensive scenario coverage including edge cases.
Excessive Mock Usage Warning ✅ Passed The test file demonstrates appropriate mock usage with no excessive mocking; the new test method directly instantiates real FileComponent objects and tests core logic without mocks.

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.

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.13%. Comparing base (c74502e) to head (6a87a83).
⚠️ Report is 4 commits behind head on main.

❌ Your project status has failed because the head coverage (39.97%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10520   +/-   ##
=======================================
  Coverage   32.13%   32.13%           
=======================================
  Files        1364     1364           
  Lines       62496    62496           
  Branches     9249     9249           
=======================================
  Hits        20082    20082           
  Misses      41401    41401           
  Partials     1013     1013           
Flag Coverage Δ
backend 50.62% <ø> (ø)
frontend 14.15% <ø> (ø)
lfx 39.97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
15.31% (4187/27344) 8.48% (1764/20798) 9.61% (579/6024)

Unit Test Results

Tests Skipped Failures Errors Time
1638 0 💤 0 ❌ 0 🔥 20.414s ⏱️

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (1)

2995-3035: Advanced-mode gating vs compatibility list: csv listed as Docling-compatible but UI forbids it.

UI gating hides Advanced Parser when any path endswith .csv/.xlsx/.parquet, yet _is_docling_compatible treats “.csv” as compatible. This inconsistency can surprise users if advanced_mode is set programmatically.

Consider removing “.csv” (and optionally spreadsheet formats) from the Docling compatibility list, or allow advanced_mode for these in the gating check. Example patch (remove csv from tuple):

-        docling_exts = (
+        docling_exts = (
             ".adoc",
             ".asciidoc",
             ".asc",
             ".bmp",
-            ".csv",
             ".dotx",
             ".dotm",
             ".docm",
             ".docx",
             ".htm",
             ".html",
             ".jpg",
             ".jpeg",
             ".json",
             ".md",
             ".pdf",
             ".png",
             ".potx",
             ".ppsx",
             ".pptm",
             ".potm",
             ".ppsm",
             ".pptx",
             ".tiff",
             ".txt",
             ".xls",
             ".xlsx",
             ".xhtml",
             ".xml",
             ".webp",
         )
🧹 Nitpick comments (2)
src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (2)

3065-3110: Path “blacklist” is unnecessary and may reject valid filenames.

Since subprocess.run uses an argv list (no shell), characters like $, &, ;, ` are not interpreted. The check can block legitimate filenames. Prefer allowing all paths or restrict via allowlist (e.g., existence + isfile) instead.

-        if not isinstance(args["file_path"], str) or any(c in args["file_path"] for c in [";", "|", "&", "$", "`"]):
-            return Data(data={"error": "Unsafe file path detected.", "file_path": args["file_path"]})
+        # Basic validation without disallowing valid characters; avoid shell, already using argv list.
+        if not isinstance(args["file_path"], str) or not args["file_path"]:
+            return Data(data={"error": "Invalid file path.", "file_path": args.get("file_path")})

2925-2960: Minor: simplify file_path retrieval in update_outputs.

You already computed paths = self._path_value(template). Reusing paths[0] is enough regardless of field_name.

-            file_path = paths[0] if field_name == "path" else frontend_node["template"]["path"]["file_path"][0]
+            file_path = paths[0]
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e8a558 and c62df86.

📒 Files selected for processing (7)
  • src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (1 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (2 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (2 hunks)
  • src/backend/tests/unit/components/data/test_file_component.py (1 hunks)
  • src/lfx/src/lfx/components/data/file.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/backend/tests/unit/components/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

src/backend/tests/unit/components/**/*.py: Mirror the component directory structure for unit tests in src/backend/tests/unit/components/
Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
Provide file_names_mapping for backward compatibility in component tests
Create comprehensive unit tests for all new components

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
{src/backend/**/*.py,tests/**/*.py,Makefile}

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
src/backend/tests/unit/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Test component integration within flows using create_flow, build_flow, and get_build_events utilities

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
src/backend/tests/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
src/backend/**/*component*.py

📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)

In your Python component class, set the icon attribute to a string matching the frontend icon mapping exactly (case-sensitive).

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
src/backend/**/components/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)

In your Python component class, set the icon attribute to a string matching the frontend icon mapping exactly (case-sensitive).

Files:

  • src/backend/tests/unit/components/data/test_file_component.py
🧠 Learnings (5)
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components

Applied to files:

  • src/backend/tests/unit/components/data/test_file_component.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test component configuration updates in backend Python tests by asserting correct updates to build configuration objects.

Applied to files:

  • src/backend/tests/unit/components/data/test_file_component.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure for unit tests in src/backend/tests/unit/components/

Applied to files:

  • src/backend/tests/unit/components/data/test_file_component.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Validate input/output behavior and test component initialization and configuration in backend Python tests.

Applied to files:

  • src/backend/tests/unit/components/data/test_file_component.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Starter project files auto-format after langflow run; these formatting changes can be committed or ignored

Applied to files:

  • src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json
  • src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json
  • src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json
  • src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json
🧬 Code graph analysis (1)
src/backend/tests/unit/components/data/test_file_component.py (1)
src/lfx/src/lfx/components/data/file.py (1)
  • update_outputs (201-245)
🪛 GitHub Actions: Ruff Style Check
src/lfx/src/lfx/components/data/file.py

[error] 216-216: E501 Line too long (128 > 120)

🪛 GitHub Check: Ruff Style Check (3.13)
src/lfx/src/lfx/components/data/file.py

[failure] 243-243: Ruff (E501)
src/lfx/src/lfx/components/data/file.py:243:121: E501 Line too long (128 > 120)


[failure] 229-229: Ruff (E501)
src/lfx/src/lfx/components/data/file.py:229:121: E501 Line too long (124 > 120)


[failure] 226-226: Ruff (E501)
src/lfx/src/lfx/components/data/file.py:226:121: E501 Line too long (135 > 120)


[failure] 216-216: Ruff (E501)
src/lfx/src/lfx/components/data/file.py:216:121: E501 Line too long (128 > 120)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Test Docker Images / Test docker images
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Test Starter Templates
  • GitHub Check: Optimize new Python code in this PR
  • GitHub Check: Update Component Index
  • GitHub Check: test-starter-projects
🔇 Additional comments (10)
src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (2)

1208-1212: PR description vs. diff: this is a functional change, not just a code_hash update

The File component’s embedded code and outputs have been altered (e.g., new tooling logic, tool_mode propagation). The PR description claims only metadata/hash changes. Please update the PR summary to reflect the functional changes so reviewers understand scope.


1225-1239: Good: Raw Content output exposes tool_mode for File component

Adding tool_mode: true on the "Raw Content" output aligns the starter with tool-mode agent flows and matches the stated objective.

src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (3)

2342-2342: Code hash update reflects tool_mode propagation in File component.

The code_hash change from 85abc1094130 to da942f5bd4d9 is expected and aligns with the PR objective to add tool_mode=True to the File component's Output declarations. This hash update indicates the underlying FileComponent source code has been modified.

Per the retrieved learning, starter project files auto-format after langflow run; these metadata changes can be committed.


2356-2371: File component outputs correctly declare tool_mode=True.

The "Raw Content" output at line 2365 correctly sets "tool_mode": true, which aligns with the PR objective to support tool mode in dynamic outputs. This change ensures the File component output can be used in tool mode contexts.


2394-2411: Embedded FileComponent source code reflects tool_mode additions.

The embedded Python code in the File component's code field (lines 2394–2411) contains the source implementation of FileComponent with updated Output declarations that include tool_mode=True. This is consistent with the PR's objective to propagate tool_mode across the File component's outputs.

For example, at the end of the code snippet, the outputs definition includes:

Output(display_name="Raw Content", name="message", method="load_files_message", tool_mode=True),

This confirms the tool_mode parameter is properly integrated into the component definition.

src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (2)

934-934: LGTM: Metadata update reflects component changes.

The code_hash update correctly reflects the modified File component implementation that now includes tool_mode support in outputs.

Based on learnings: Starter project files auto-format after langflow run; these formatting changes can be committed.


1002-1002: LGTM: Embedded code reflects updated File component.

The embedded File component code correctly includes the tool_mode=True parameter in Output declarations, consistent with the changes in the actual component implementation.

src/backend/tests/unit/components/data/test_file_component.py (1)

144-188: LGTM: Comprehensive test coverage for tool_mode propagation.

This test effectively validates that tool_mode=True is consistently set across all dynamic output scenarios. The test covers:

  • Single CSV/JSON files
  • Multiple files
  • Advanced mode enabled/disabled

The clear docstring and descriptive assertions make the test easy to understand and maintain.

As per coding guidelines: Test validates input/output behavior and component configuration, following the recommended patterns for comprehensive component testing.

src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (2)

2746-3110: tool_mode enabled across File outputs and dynamic update paths — LGTM.

Outputs include tool_mode=True for Raw Content and all branches in update_outputs (structured/json/advanced/multi-file). This aligns with tool mode behavior.

Please run the unit test that validates dynamic outputs have tool_mode=True to ensure parity with this embedded component.


2678-2679: No issues found—code_hash regeneration and tool_mode settings are correct.

Verification confirms:

  • Code hash "da942f5bd4d9" appears exactly once (correct, no duplicates)
  • All outputs have tool_mode=True properly set—both the static output definition and all 7 dynamically generated outputs in update_outputs() method

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 6, 2025
@github-actions github-actions bot removed the bug Something isn't working label Nov 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 24, 2025
@erichare erichare added this pull request to the merge queue Nov 24, 2025
Merged via the queue into main with commit f564680 Nov 24, 2025
81 of 82 checks passed
@erichare erichare deleted the fix-file-component-toolmode branch November 24, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants