Skip to content

feat(components): add Bilig WorkPaper formula readback#13309

Open
gregkonush wants to merge 6 commits into
langflow-ai:release-1.10.0from
gregkonush:codex/bilig-workpaper-component
Open

feat(components): add Bilig WorkPaper formula readback#13309
gregkonush wants to merge 6 commits into
langflow-ai:release-1.10.0from
gregkonush:codex/bilig-workpaper-component

Conversation

@gregkonush
Copy link
Copy Markdown

@gregkonush gregkonush commented May 23, 2026

Adds a new BiligWorkPaperFormulaReadbackComponent under lfx.components.bilig.

The component gives Langflow builders one focused canvas node for spreadsheet-backed formula verification: write an input cell through a configured Bilig WorkPaper API, recalculate formulas, and return compact JSON proof that the computed output changed and persisted. It defaults to the hosted Bilig demo endpoint and keeps base_url configurable for self-hosted/private WorkPaper deployments.

Implementation details:

  • New vendor component folder: src/lfx/src/lfx/components/bilig
  • Visible tool-mode inputs for sheet_name, address, and value
  • Advanced base_url and timeout settings
  • httpx request path with explicit JSON proof validation
  • Unit coverage for request construction and compact readback output

Validation:

uv run --no-project --with ruff ruff check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/bilig

uv run --no-project --with ruff ruff format --check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/bilig

PYTHONPATH=src/lfx/src uv run --no-project --with pytest --with pydantic --with langchain-core --with nanoid --with loguru --with pandas --with structlog --with platformdirs --with fastapi --with filelock --with aiofiles --with pillow --with docstring-parser --with cachetools --with emoji --with httpx python -m pytest src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py

Also verified the hosted Bilig endpoint returns verified=true, after.expectedArr=96000, and restoredMatchesAfter=true.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

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.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 70ae2acc-fae6-4f1f-9c94-36ff147e0ddf

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

A new bilig component integrates with an external Bilig API to verify spreadsheet formula readback. The component is registered in the framework's dynamic import system, implemented with HTTP orchestration and proof compaction logic, and validated through unit tests with mocked HTTP clients.

Changes

Bilig Component Integration

Layer / File(s) Summary
Framework Registration
src/lfx/src/lfx/components/__init__.py
bilig is added to TYPE_CHECKING imports, the _dynamic_imports lazy-loading mapping as a module-backed entry, and the public __all__ list for framework discovery.
Component Implementation and Helpers
src/lfx/src/lfx/components/bilig/workpaper_formula_readback.py
BiligWorkPaperFormulaReadbackComponent exposes configurable Bilig API parameters and calls call_bilig_forecast, which validates base URL, POSTs to the WorkPaper forecast endpoint, enforces HTTP success and response structure, and requires verified: true. The verify_formula_readback method orchestrates the call, compacts the proof via compact_proof, and handles exceptions by setting status and returning error payloads. compact_proof normalizes and extracts selected proof fields into a structured result with fixed metadata.
Package-Level Export
src/lfx/src/lfx/components/bilig/__init__.py
BiligWorkPaperFormulaReadbackComponent is imported and re-exported via __all__.
Component and Helper Tests
src/lfx/tests/unit/components/bilig/*.py
Fake HTTP client and response helpers mock httpx.Client to capture request details. test_call_bilig_forecast_posts_expected_payload verifies the function POSTs the correct payload and returns the expected response. test_component_returns_compact_formula_readback_proof instantiates the component, mocks the HTTP client, and asserts result.data matches the API response plus source and github metadata, with component.status equal to that dict.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Quality And Coverage ⚠️ Warning Tests cover success paths and some error validation but lack coverage for httpx.HTTPError, TimeoutError, TypeError non-dict responses, and compact_proof edge cases. Add tests for httpx.HTTPError, TimeoutError, non-dict JSON responses, component default values, and compact_proof with missing/invalid fields.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(components): add Bilig WorkPaper formula readback' directly and clearly summarizes the main change: introducing a new Bilig WorkPaper formula readback component to the components module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Coverage For New Implementations ✅ Passed PR includes 5 unit tests in test_workpaper_formula_readback.py with proper test_*.py naming, covering all functions, success/error paths, and validation with real assertions.
Test File Naming And Structure ✅ Passed test_workpaper_formula_readback.py follows test_*.py pattern with pytest structure, 5 descriptive tests covering positive and negative scenarios with edge cases and proper organization.
Excessive Mock Usage Warning ✅ Passed 2 minimal mocks replace external httpx.Client dependency appropriately; real business logic tested without mocks, error handling and transformations verified through assertions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 enhancement New feature or request and removed enhancement New feature or request labels May 23, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 23, 2026
Copy link
Copy Markdown
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: 1

🧹 Nitpick comments (1)
src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py (1)

37-127: ⚡ Quick win

Add negative-path tests for input/API failure handling.

Current coverage is success-only. Please add at least one validation-failure case and one unverified-response case so error handling remains regression-safe.

Example additions
+import pytest
+
@@
 def test_component_returns_compact_formula_readback_proof(monkeypatch):
@@
     assert component.status == result.data
+
+
+def test_call_bilig_forecast_rejects_non_http_base_url():
+    with pytest.raises(ValueError, match="base_url must start with http:// or https://"):
+        call_bilig_forecast(
+            base_url="ftp://bilig.example",
+            sheet_name="Inputs",
+            address="B3",
+            value=0.4,
+            timeout=7,
+        )
+
+
+def test_component_returns_error_when_response_is_unverified(monkeypatch):
+    def fake_client(*, timeout, headers):
+        return FakeClient(
+            captured={},
+            timeout=timeout,
+            headers=headers,
+            response=FakeResponse({"verified": False}),
+        )
+
+    monkeypatch.setattr("lfx.components.bilig.workpaper_formula_readback.httpx.Client", fake_client)
+    component = BiligWorkPaperFormulaReadbackComponent()
+    component.base_url = "https://bilig.example"
+    component.sheet_name = "Inputs"
+    component.address = "B3"
+    component.value = 0.4
+    component.timeout = 7
+
+    result = component.verify_formula_readback()
+    assert "error" in result.data
+    assert isinstance(component.status, str)

As per coding guidelines: "Consider including edge cases and error conditions for comprehensive test coverage" and "Verify tests cover both positive and negative scenarios where appropriate".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py`
around lines 37 - 127, Add negative-path tests: create one test that simulates
validation failure by calling call_bilig_forecast or
BiligWorkPaperFormulaReadbackComponent with invalid inputs (e.g., missing/empty
sheet_name or malformed address) and assert the function/component raises the
expected ValidationError or returns an error status; and create another test
that uses FakeClient/FakeResponse to return {"verified": False, ...} from
call_bilig_forecast (or from the component via verify_formula_readback) and
assert the component returns/raises the unverified-path behavior your code
implements (e.g., result["verified"] is False or component.status shows an
error). Locate helpers around call_bilig_forecast and
BiligWorkPaperFormulaReadbackComponent.verify_formula_readback to patch
httpx.Client and reuse FakeClient/FakeResponse to craft the failing responses.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lfx/src/lfx/components/bilig/workpaper_formula_readback.py`:
- Around line 111-113: The error currently raises ValueError with the entire
upstream payload (parsed) which can leak sensitive data; change the raise to
include only safe, minimal info (e.g., verification status and a non-sensitive
identifier) instead of the full payload: replace msg = f"Unverified WorkPaper
response: {parsed}" and raise ValueError(msg) with something like raising
ValueError(f"Unverified WorkPaper response (verified={parsed.get('verified')})
for workpaper_id={parsed.get('workpaper_id') or parsed.get('id') or 'unknown'}")
or a similar safe summary, ensuring you reference the same parsed variable and
use the existing raise ValueError call.

---

Nitpick comments:
In `@src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py`:
- Around line 37-127: Add negative-path tests: create one test that simulates
validation failure by calling call_bilig_forecast or
BiligWorkPaperFormulaReadbackComponent with invalid inputs (e.g., missing/empty
sheet_name or malformed address) and assert the function/component raises the
expected ValidationError or returns an error status; and create another test
that uses FakeClient/FakeResponse to return {"verified": False, ...} from
call_bilig_forecast (or from the component via verify_formula_readback) and
assert the component returns/raises the unverified-path behavior your code
implements (e.g., result["verified"] is False or component.status shows an
error). Locate helpers around call_bilig_forecast and
BiligWorkPaperFormulaReadbackComponent.verify_formula_readback to patch
httpx.Client and reuse FakeClient/FakeResponse to craft the failing responses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e0d3101-7d58-41be-8194-7d30d63f8fae

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe9b39 and 32d87eb.

📒 Files selected for processing (5)
  • src/lfx/src/lfx/components/__init__.py
  • src/lfx/src/lfx/components/bilig/__init__.py
  • src/lfx/src/lfx/components/bilig/workpaper_formula_readback.py
  • src/lfx/tests/unit/components/bilig/__init__.py
  • src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py

Comment thread src/lfx/src/lfx/components/bilig/workpaper_formula_readback.py
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 23, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 23, 2026
@gregkonush
Copy link
Copy Markdown
Author

gregkonush commented May 23, 2026

CI note: the current red frontend check did not reach the Bilig component code. The failed shard died during actions/checkout before tests ran:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

The branch already includes the CodeRabbit safety fix and negative-path tests for unverified upstream responses. Local targeted validation from the PR branch is green:

uv run --no-project --with ruff ruff check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/bilig
uv run --no-project --with ruff ruff format --check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/bilig
PYTHONPATH=src/lfx/src uv run --no-project ... python -m pytest src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py

Result: ruff check passed, ruff format check passed, and the Bilig unit test file passed with 5 passed. I do not have permission to rerun failed jobs on the upstream repo, so this likely needs a maintainer rerun rather than a code change.

@gregkonush
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 24, 2026
@gregkonush
Copy link
Copy Markdown
Author

CI triage: the current red checks look unrelated to this PR code.

Both failed jobs died during actions/checkout before tests ran, while fetching the PR merge ref:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

The coverage merge failure follows from that shard not producing its blob report. I tried to rerun only the failed jobs, but GitHub requires repository admin rights for that action. Could a maintainer rerun the failed jobs when convenient?

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 25, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant