Skip to content

Conversation

@Cristhianzl
Copy link
Member

@Cristhianzl Cristhianzl commented Dec 1, 2025

Summary

  • Fixed transaction logging to actually save data to the database instead of only debug logging
  • Added TransactionLogsResponse model to return only necessary fields for logs view
  • Fixed inputs/outputs display showing [object Object] by adding proper JSON formatting
  • Added status badge styling with success/error variants
  • Added comprehensive test coverage for both backend and frontend

Changes

Backend

  • monitor.py: Updated endpoint to use new transformer and descending timestamp order
  • transactions/model.py: Added TransactionLogsResponse model excluding error and flow_id fields
  • transactions/crud.py: Added transform_transaction_table_for_logs function
  • lfx/graph/utils.py: Fixed log_transaction to save to database using langflow's services
  • lfx/graph/vertex/base.py: Added transaction logging calls after successful build and on error

Frontend

  • flowLogsModal/config/flowLogsColumns.tsx: New file with column definitions and Badge component for status styling
  • tests/core/features/logs.spec.ts: Fixed selectors to use exact match within dialog scope
  • tests/extended/features/flow-logs-modal.spec.ts: New comprehensive E2E tests

Tests

  • Added 15 backend unit tests for transaction models, transformers, and endpoints
  • Added 5 frontend E2E tests covering:
    • Modal open/close functionality
    • "No Data Available" state
    • Success status display after component execution
    • Error status display after failed component execution
image image

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 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

This PR introduces transaction logging for flow execution. The backend adds a new TransactionLogsResponse model and transformer to expose transaction logs via the API. The LFX graph module now captures transaction data during vertex execution (success and error states) and persists it to the database. The frontend displays these logs in a modal with columns for timestamp, component, target, inputs, outputs, and status.

Changes

Cohort / File(s) Summary
Backend Transaction Models & API
src/backend/base/langflow/services/database/models/transactions/model.py, src/backend/base/langflow/services/database/models/transactions/crud.py, src/backend/base/langflow/api/v1/monitor.py
Added new TransactionLogsResponse SQLModel with serializers for inputs/outputs. Created transform_transaction_table_for_logs transformer. Updated /monitor/transactions endpoint to return TransactionLogsResponse pages instead of TransactionTable pages, with descending timestamp ordering.
Backend Tests
src/backend/tests/unit/api/v1/test_transactions.py
Added comprehensive unit tests covering transaction model creation, flow ID handling, TransactionLogsResponse construction, transformers (transform_transaction_table, transform_transaction_table_for_logs), and endpoint behaviors (auth, pagination, parameter validation, response structure).
Frontend Logs Modal & Config
src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx, src/frontend/src/modals/flowLogsModal/index.tsx
Extracted AG Grid column definitions into createFlowLogsColumns() helper with six columns: Timestamp, Component, Target, Inputs, Outputs, Status. Status column uses custom Badge renderer based on value. Refactored modal to use config-driven columns instead of state-based definition.
Frontend Tests
src/frontend/tests/core/features/logs.spec.ts, src/frontend/tests/extended/features/flow-logs-modal.spec.ts
Updated existing test header checks to match new column names. Added extensive new test suite covering modal opening/closing, no-data handling, success/error status badges, custom component interactions, and end-to-end flow execution with log verification.
LFX Graph Transaction Logging
src/lfx/src/lfx/graph/utils.py, src/lfx/src/lfx/graph/vertex/base.py
Enhanced log_transaction to construct full TransactionBase objects with vertex_id, target_id, inputs, outputs, status, and error. Added checks for settings service availability and transactions storage enablement. Integrated database write via LangFlow DB service with proper session handling. Modified vertex execution to call log_transaction with "error" status on exceptions and "success" status after successful builds.

Sequence Diagram

sequenceDiagram
    participant Vertex as Vertex.build()
    participant Logger as log_transaction()
    participant Settings as Settings Service
    participant DBService as LangFlow DB Service
    participant CRUD as Transaction CRUD
    participant DB as Database

    Vertex->>Vertex: Execute vertex logic
    
    rect rgb(200, 220, 240)
    Note over Vertex,CRUD: Success Path
    Vertex->>Logger: log_transaction(status="success")
    Logger->>Settings: Check transactions_storage_enabled
    Settings-->>Logger: Enabled
    Logger->>DBService: Get DB service instance
    DBService-->>Logger: Service ready
    Logger->>CRUD: log_transaction(TransactionBase)
    CRUD->>DB: INSERT transaction record
    DB-->>CRUD: Record persisted
    CRUD-->>Logger: Complete
    end

    rect rgb(240, 200, 200)
    Note over Vertex,CRUD: Error Path
    Vertex->>Vertex: Exception in _build_results
    Vertex->>Logger: log_transaction(status="error")
    Logger->>Settings: Check transactions_storage_enabled
    Settings-->>Logger: Enabled
    Logger->>DBService: Get DB service instance
    DBService-->>Logger: Service ready
    Logger->>CRUD: log_transaction(TransactionBase with error)
    CRUD->>DB: INSERT transaction record
    DB-->>CRUD: Record persisted
    CRUD-->>Logger: Complete
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35–50 minutes

Key areas requiring attention during review:

  • Circular dependency handling in LFX: The log_transaction function uses local imports to avoid circular dependencies; verify the import strategy is sound and settings/DB service access is properly scoped.
  • Transaction model serialization: Field serializers for inputs/outputs enforce text length and item count limits; ensure these align with expected log data sizes and don't truncate critical information.
  • Frontend column rendering: Status Badge cellRenderer uses variant mapping; verify all possible status values are handled (success, error, pending, etc.).
  • Flow ID UUID normalization: Confirm flow_id is consistently converted to UUID throughout the transaction logging pipeline.

Possibly related PRs

Suggested labels

enhancement, lgtm

Suggested reviewers

  • erichare
  • edwinjosechittilappilly

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

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

❌ Failed checks (1 error, 3 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error Test coverage incomplete: LFX graph modules (utils.py, vertex/base.py) lack unit tests; review comments identify assertion bugs in existing tests. Add unit tests for lfx/graph/utils.py and vertex/base.py covering database persistence and error handling. Fix return type annotation bug in transform_transaction_table_for_logs. Fix test assertions to properly wrap isVisible() and locator() calls with expect().
Docstring Coverage ⚠️ Warning Docstring coverage is 73.08% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Test Quality And Coverage ⚠️ Warning Frontend tests have assertion issues: isVisible() called without expect() on lines 73, 84, 95; success badge check not scoped to dialog. Backend tests lack @pytest.mark.asyncio consistency, don't test async log_transaction, source=None guards, database failures, or type annotation correctness for transform_transaction_table_for_logs. Fix frontend assertions by wrapping isVisible() with await expect() and scoping success check to dialog. Add consistent @pytest.mark.asyncio to async backend tests, test async log_transaction, database errors, source=None, settings unavailability, and verify transformer return types match annotations.
Test File Naming And Structure ⚠️ Warning The logs.spec.ts file contains assertion violations: line 73 calls isVisible() without expect() wrapping, and line 76 searches entire page instead of scoping to dialog component. Wrap isVisible() with expect() on line 73 and scope success status check to dialog component on line 76 using dialog.locator() instead of page.locator().
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of the PR: restoring logs modal functionality with transaction logging and proper display, matching the comprehensive changes across backend and frontend.
Excessive Mock Usage Warning ✅ Passed Backend unit tests use real model objects rather than mocks, and frontend E2E tests contain zero mocks, demonstrating appropriate test architecture.

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 Dec 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 17%
16.64% (4686/28153) 10.01% (2179/21765) 10.93% (676/6184)

Unit Test Results

Tests Skipped Failures Errors Time
1829 0 💤 0 ❌ 0 🔥 24.377s ⏱️

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 38.88889% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.14%. Comparing base (909bdb1) to head (21d806d).

Files with missing lines Patch % Lines
...rc/modals/flowLogsModal/config/flowLogsColumns.tsx 0.00% 20 Missing ⚠️
src/lfx/src/lfx/graph/utils.py 11.76% 14 Missing and 1 partial ⚠️
src/lfx/src/lfx/graph/vertex/base.py 60.00% 3 Missing and 1 partial ⚠️
src/frontend/src/modals/flowLogsModal/index.tsx 0.00% 3 Missing ⚠️
...low/services/database/models/transactions/model.py 86.66% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10820      +/-   ##
==========================================
+ Coverage   33.09%   33.14%   +0.05%     
==========================================
  Files        1389     1390       +1     
  Lines       65682    65734      +52     
  Branches     9720     9728       +8     
==========================================
+ Hits        21737    21789      +52     
- Misses      42830    42833       +3     
+ Partials     1115     1112       -3     
Flag Coverage Δ
backend 52.65% <90.90%> (+0.25%) ⬆️
frontend 15.33% <0.00%> (-0.02%) ⬇️
lfx 39.17% <29.62%> (-0.04%) ⬇️

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

Files with missing lines Coverage Δ
src/backend/base/langflow/api/v1/monitor.py 49.19% <100.00%> (ø)
...flow/services/database/models/transactions/crud.py 78.78% <100.00%> (+40.85%) ⬆️
...low/services/database/models/transactions/model.py 90.16% <86.66%> (+14.07%) ⬆️
src/frontend/src/modals/flowLogsModal/index.tsx 0.00% <0.00%> (ø)
src/lfx/src/lfx/graph/vertex/base.py 57.26% <60.00%> (+0.05%) ⬆️
src/lfx/src/lfx/graph/utils.py 27.77% <11.76%> (-2.08%) ⬇️
...rc/modals/flowLogsModal/config/flowLogsColumns.tsx 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

🚀 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 Dec 1, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
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: 4

Caution

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

⚠️ Outside diff range comments (2)
src/lfx/src/lfx/graph/utils.py (1)

129-133: Potential AttributeError if source is None.

Line 130 accesses source.graph.flow_id without checking if source is None. However, line 144 suggests source can be None (if source else None). If source is None and flow_id is falsy, this will raise an AttributeError.

         if not flow_id:
-            if source.graph.flow_id:
+            if source and source.graph.flow_id:
                 flow_id = source.graph.flow_id
             else:
                 return
src/lfx/src/lfx/graph/vertex/base.py (1)

530-556: Remove the blocking await and add proper cancellation error handling for background task logging.

The await task on line 550 blocks the calling coroutine during I/O-bound database operations, unnecessarily stalling the vertex build process. Since log_transaction performs async database operations, this synchronous wait extends the block to all callers of _log_transaction_async (lines 572, 578, 663, 784).

Background logging tasks should run concurrently with proper cleanup. Remove the await task and instead rely on the done callback to manage completed tasks. Additionally, implement try/except handling for asyncio.CancelledError as required by backend development guidelines, wrapping the task creation and management logic.

🧹 Nitpick comments (6)
src/lfx/src/lfx/graph/utils.py (1)

167-168: Silent exception swallowing may hide issues during debugging.

The broad except Exception clause logs errors only at the debug level, which means transaction logging failures will be invisible unless debug logging is enabled. While this is likely intentional to prevent logging failures from affecting flow execution, consider logging at warning level for unexpected errors to aid in debugging production issues.

     except Exception as exc:  # noqa: BLE001
-        logger.debug(f"Error logging transaction: {exc!s}")
+        logger.warning(f"Error logging transaction: {exc!s}")

Alternatively, keep debug level but ensure documentation notes this behavior.

src/backend/tests/unit/api/v1/test_transactions.py (1)

88-111: Simplify field exclusion assertion for better clarity.

Line 109 uses a complex assertion pattern to verify that error and flow_id are excluded from TransactionLogsResponse. Consider using a more direct check.

Apply this diff for clearer assertions:

         response = TransactionLogsResponse.model_validate(table, from_attributes=True)

         assert response.id == table.id
         assert response.vertex_id == table.vertex_id
         assert response.target_id == table.target_id
         assert response.status == table.status
         # TransactionLogsResponse should not have error and flow_id fields
-        assert not hasattr(response, "error") or "error" not in response.model_fields
-        assert not hasattr(response, "flow_id") or "flow_id" not in response.model_fields
+        assert "error" not in response.model_fields
+        assert "flow_id" not in response.model_fields
src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx (1)

1-108: Make Inputs/Outputs columns read‑only and slightly harden status rendering

The overall column config and formatObjectValue helper look good and solve the [object Object] issue. Two small tweaks would better match a read‑only logs view and handle edge cases:

  1. Inputs/Outputs should likely be non‑editable

These are historical log entries; making them editable can confuse users and may interact oddly with AG Grid’s edit flows:

    {
      headerName: "Inputs",
      field: "inputs",
      flex: 1.2,
      minWidth: 150,
      filter: false,
      sortable: false,
-     editable: true,
+     editable: false,
      cellClass: baseCellClass,
      valueGetter: (params) => formatObjectValue(params.data?.inputs),
    },
    {
      headerName: "Outputs",
      field: "outputs",
      flex: 1.2,
      minWidth: 150,
      filter: false,
      sortable: false,
-     editable: true,
+     editable: false,
      cellClass: baseCellClass,
      valueGetter: (params) => formatObjectValue(params.data?.outputs),
    },
  1. Guard against missing status values

If status is ever undefined or null, you can avoid rendering "undefined" in the badge:

-      cellRenderer: (params: { value: string }) => {
-        const status = params.value;
+      cellRenderer: (params: { value: string | undefined | null }) => {
+        const status = params.value ?? "";

This keeps the UI clean even for unexpected data.

src/frontend/src/modals/flowLogsModal/index.tsx (2)

36-47: Avoid mutating query data when normalizing timestamps

In the useEffect you currently:

if (data) {
  const { rows } = data;

  if (data?.rows?.length > 0) {
    data.rows.map((row: any) => {
      row.timestamp = convertUTCToLocalTimezone(row.timestamp);
    });
  }

  setRows(rows);
}

This mutates data.rows in place. If useGetTransactionsQuery caches its responses (as React Query/RTK Query style hooks do), in‑place mutation can have surprising effects elsewhere.

You can keep the behavior but avoid mutation by mapping to a new array:

if (data?.rows) {
  const normalizedRows = data.rows.map((row: any) => ({
    ...row,
    timestamp: convertUTCToLocalTimezone(row.timestamp),
  }));
  setRows(normalizedRows);
} else {
  setRows([]);
}

This keeps query results immutable and makes the transformation intent clearer.


20-25: Consider memoizing static column definitions

createFlowLogsColumns() returns a static set of column definitions, but it’s called on every render:

const columns = createFlowLogsColumns();

With AG Grid, changing the columnDefs array identity can trigger additional work. It’s minor here, but you can stabilize it with useMemo:

const columns = useMemo(() => createFlowLogsColumns(), []);

(You’ll need to import useMemo.) This keeps the grid configuration stable while still being simple.

src/frontend/tests/extended/features/flow-logs-modal.spec.ts (1)

120-207: Scope success/error badge assertions to the logs dialog

In the success and error tests you currently assert on "success" / "error" across the whole page:

await expect(page.locator("text=success").first()).toBeVisible();
...
await expect(page.locator("text=error").first()).toBeVisible();

This can match unrelated text (e.g., toasts or other components) and still pass even if the logs dialog doesn’t render the badge correctly.

Since this is specifically about the Flow Logs Modal, consider scoping to the dialog similar to the core logs test:

-      // Verify success status badge is displayed
-      await expect(page.locator("text=success").first()).toBeVisible();
+      // Verify success status badge is displayed inside the logs dialog
+      const dialog = page.getByLabel("Dialog");
+      await expect(dialog.locator("text=success").first()).toBeVisible();
@@
-      // Verify error status badge is displayed
-      await expect(page.locator("text=error").first()).toBeVisible();
+      // Verify error status badge is displayed inside the logs dialog
+      const dialog = page.getByLabel("Dialog");
+      await expect(dialog.locator("text=error").first()).toBeVisible();

This keeps the assertions tightly coupled to the modal under test and reduces flakiness.

📜 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 461a032 and 12c743e.

📒 Files selected for processing (10)
  • src/backend/base/langflow/api/v1/monitor.py (2 hunks)
  • src/backend/base/langflow/services/database/models/transactions/crud.py (2 hunks)
  • src/backend/base/langflow/services/database/models/transactions/model.py (1 hunks)
  • src/backend/tests/unit/api/v1/test_transactions.py (1 hunks)
  • src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx (1 hunks)
  • src/frontend/src/modals/flowLogsModal/index.tsx (3 hunks)
  • src/frontend/tests/core/features/logs.spec.ts (1 hunks)
  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts (1 hunks)
  • src/lfx/src/lfx/graph/utils.py (2 hunks)
  • src/lfx/src/lfx/graph/vertex/base.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
src/backend/**/*.py

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

src/backend/**/*.py: Use FastAPI async patterns with await for async operations in component execution methods
Use asyncio.create_task() for background tasks and implement proper cleanup with try/except for asyncio.CancelledError
Use queue.put_nowait() for non-blocking queue operations and asyncio.wait_for() with timeouts for controlled get operations

Files:

  • src/backend/base/langflow/services/database/models/transactions/crud.py
  • src/backend/base/langflow/services/database/models/transactions/model.py
  • src/backend/tests/unit/api/v1/test_transactions.py
  • src/backend/base/langflow/api/v1/monitor.py
src/backend/base/langflow/services/database/models/**/*.py

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

Database models should be organized by domain (api_key/, flow/, folder/, user/, etc.) under src/backend/base/langflow/services/database/models/

Files:

  • src/backend/base/langflow/services/database/models/transactions/crud.py
  • src/backend/base/langflow/services/database/models/transactions/model.py
src/frontend/src/**/*.{ts,tsx}

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

src/frontend/src/**/*.{ts,tsx}: Use React 18 with TypeScript for frontend development
Use Zustand for state management

Files:

  • src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx
  • src/frontend/src/modals/flowLogsModal/index.tsx
src/frontend/src/**/*.{tsx,jsx,css,scss}

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

Use Tailwind CSS for styling

Files:

  • src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx
  • src/frontend/src/modals/flowLogsModal/index.tsx
src/frontend/src/**/*.{tsx,jsx}

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

src/frontend/src/**/*.{tsx,jsx}: Implement dark mode support using the useDarkMode hook and dark store
Use Lucide React for icon components in the application

Files:

  • src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx
  • src/frontend/src/modals/flowLogsModal/index.tsx
src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx}

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

src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx}: Use @pytest.mark.asyncio decorator for async frontend tests; structure tests to verify component behavior, state updates, and proper cleanup
Frontend tests should validate component rendering, user interactions, state management, and async operations using appropriate testing libraries (React Testing Library, Vitest, Jest, etc.)
Document each frontend test with a clear docstring/comment explaining its purpose, the scenario being tested, and expected outcomes

Files:

  • src/frontend/tests/core/features/logs.spec.ts
  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
**/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py}

📄 CodeRabbit inference engine (Custom checks)

**/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py}: Review test files for excessive use of mocks that may indicate poor test design - check if tests have too many mock objects that obscure what's actually being tested
Warn when mocks are used instead of testing real behavior and interactions
Suggest using real objects or test doubles when mocks become excessive
Ensure mocks are used appropriately for external dependencies, not core logic
Test files should have descriptive test function names that explain what is being tested
Tests should be organized logically with proper setup and teardown
Consider including edge cases and error conditions for comprehensive coverage
Verify tests cover both positive and negative scenarios where appropriate
Tests should cover the main functionality being implemented
Check that tests are not just smoke tests but actually validate behavior
Ensure tests follow the project's testing patterns (pytest for backend, Playwright for frontend)
For API endpoints, verify both success and error response testing

Files:

  • src/frontend/tests/core/features/logs.spec.ts
  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
src/backend/tests/**/*.py

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

src/backend/tests/**/*.py: Place backend unit tests in src/backend/tests/ directory, component tests in src/backend/tests/unit/components/ organized by component subdirectory, and integration tests accessible via make integration_tests
Use same filename as component with appropriate test prefix/suffix (e.g., my_component.pytest_my_component.py)
Use the client fixture (FastAPI Test Client) defined in src/backend/tests/conftest.py for API tests; it provides an async httpx.AsyncClient with automatic in-memory SQLite database and mocked environment variables. Skip client creation by marking test with @pytest.mark.noclient
Inherit from the correct ComponentTestBase family class located in src/backend/tests/base.py based on API access needs: ComponentTestBase (no API), ComponentTestBaseWithClient (needs API), or ComponentTestBaseWithoutClient (pure logic). Provide three required fixtures: component_class, default_kwargs, and file_names_mapping
Create comprehensive unit tests for all new backend components. If unit tests are incomplete, create a corresponding Markdown file documenting manual testing steps and expected outcomes
Test both sync and async code paths, mock external dependencies appropriately, test error handling and edge cases, validate input/output behavior, and test component initialization and configuration
Use @pytest.mark.asyncio decorator for async component tests and ensure async methods are properly awaited
Test background tasks using asyncio.create_task() and verify completion with asyncio.wait_for() with appropriate timeout constraints
Test queue operations using non-blocking queue.put_nowait() and asyncio.wait_for(queue.get(), timeout=...) to verify queue processing without blocking
Use @pytest.mark.no_blockbuster marker to skip the blockbuster plugin in specific tests
For database tests that may fail in batch runs, run them sequentially using uv run pytest src/backend/tests/unit/test_database.py r...

Files:

  • src/backend/tests/unit/api/v1/test_transactions.py
**/{test_*.py,*.test.ts,*.test.tsx}

📄 CodeRabbit inference engine (Custom checks)

Check that test files follow the project's naming conventions (test_*.py for backend, *.test.ts for frontend)

Files:

  • src/backend/tests/unit/api/v1/test_transactions.py
**/test_*.py

📄 CodeRabbit inference engine (Custom checks)

**/test_*.py: Backend tests should follow pytest structure with proper test_*.py naming
For async functions, ensure proper async testing patterns are used with pytest for backend

Files:

  • src/backend/tests/unit/api/v1/test_transactions.py
src/backend/base/langflow/api/**/*.py

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

Backend API endpoints should be organized by version (v1/, v2/) under src/backend/base/langflow/api/ with specific modules for features (chat.py, flows.py, users.py, etc.)

Files:

  • src/backend/base/langflow/api/v1/monitor.py
🧠 Learnings (22)
📚 Learning: 2025-11-24T19:46:45.790Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:45.790Z
Learning: Applies to src/frontend/src/components/**/*.{tsx,jsx} : Use React Flow for flow graph visualization with Node, Edge, Controls, and Background components

Applied to files:

  • src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx
  • src/frontend/src/modals/flowLogsModal/index.tsx
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx} : Document each frontend test with a clear docstring/comment explaining its purpose, the scenario being tested, and expected outcomes

Applied to files:

  • src/frontend/tests/core/features/logs.spec.ts
  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:40.400Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.400Z
Learning: Applies to **/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py} : Ensure mocks are used appropriately for external dependencies, not core logic

Applied to files:

  • src/frontend/tests/core/features/logs.spec.ts
  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-06-23T12:46:52.420Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-06-23T12:46:52.420Z
Learning: Export custom icon components in React using React.forwardRef to ensure proper ref forwarding and compatibility with parent components.

Applied to files:

  • src/frontend/src/modals/flowLogsModal/index.tsx
📚 Learning: 2025-11-24T19:46:45.790Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:45.790Z
Learning: Applies to src/frontend/src/**/*.{tsx,jsx} : Use Lucide React for icon components in the application

Applied to files:

  • src/frontend/src/modals/flowLogsModal/index.tsx
📚 Learning: 2025-06-16T11:14:04.200Z
Learnt from: dolfim-ibm
Repo: langflow-ai/langflow PR: 8394
File: src/frontend/src/icons/Docling/index.tsx:4-6
Timestamp: 2025-06-16T11:14:04.200Z
Learning: The Langflow codebase consistently uses `React.PropsWithChildren<{}>` as the prop type for all icon components using forwardRef, rather than `React.SVGProps<SVGSVGElement>`. This is an established pattern across hundreds of icon files in src/frontend/src/icons/.

Applied to files:

  • src/frontend/src/modals/flowLogsModal/index.tsx
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx} : Frontend tests should validate component rendering, user interactions, state management, and async operations using appropriate testing libraries (React Testing Library, Vitest, Jest, etc.)

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:40.400Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.400Z
Learning: Applies to **/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py} : Consider including edge cases and error conditions for comprehensive coverage

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:40.400Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.400Z
Learning: Applies to **/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py} : Tests should cover the main functionality being implemented

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/frontend/**/*.{test,spec}.{ts,tsx,js,jsx} : Use `pytest.mark.asyncio` decorator for async frontend tests; structure tests to verify component behavior, state updates, and proper cleanup

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:40.400Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.400Z
Learning: Applies to **/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py} : Ensure tests follow the project's testing patterns (pytest for backend, Playwright for frontend)

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:47:40.400Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.400Z
Learning: Applies to **/*.{test.ts,test.tsx,spec.ts,spec.tsx,test_*.py} : Verify tests cover both positive and negative scenarios where appropriate

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-11-24T19:46:45.790Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:45.790Z
Learning: Applies to src/frontend/**/*.test.{ts,tsx} : Write component tests using React Testing Library with render(), screen, and fireEvent utilities

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-06-23T12:46:42.048Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Frontend tests should be written using testing-library/react, with both component and integration tests verifying rendering, user interaction, and data loading.

Applied to files:

  • src/frontend/tests/extended/features/flow-logs-modal.spec.ts
📚 Learning: 2025-08-07T20:23:23.569Z
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 0
File: :0-0
Timestamp: 2025-08-07T20:23:23.569Z
Learning: The Langflow codebase has an excellent structlog implementation that follows best practices, with proper global configuration, environment-based output formatting, and widespread adoption across components. The main cleanup needed is updating starter project templates and documentation examples that still contain legacy `from loguru import logger` imports.

Applied to files:

  • src/lfx/src/lfx/graph/utils.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths, mock external dependencies appropriately, test error handling and edge cases, validate input/output behavior, and test component initialization and configuration

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Create comprehensive unit tests for all new backend components. If unit tests are incomplete, create a corresponding Markdown file documenting manual testing steps and expected outcomes

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow REST API endpoints using the `client` fixture with appropriate HTTP methods (GET, POST, etc.), headers (logged_in_headers), and payload validation

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Use predefined JSON flows and utility functions from `tests.unit.build_utils` (create_flow, build_flow, get_build_events, consume_and_assert_stream) for flow execution testing

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Use `monkeypatch` fixture to mock internal functions for testing error handling scenarios; validate error status codes and error message content in responses

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's `Message` objects using `langflow.schema.message.Message` and validate text, sender, sender_name, session_id, files, and properties attributes

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
  • src/backend/base/langflow/api/v1/monitor.py
📚 Learning: 2025-11-24T19:47:28.997Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.997Z
Learning: Applies to src/backend/tests/**/*.py : Test component versioning and backward compatibility using `file_names_mapping` fixture with `VersionComponentMapping` objects mapping component files across Langflow versions

Applied to files:

  • src/backend/tests/unit/api/v1/test_transactions.py
🧬 Code graph analysis (7)
src/backend/base/langflow/services/database/models/transactions/crud.py (1)
src/backend/base/langflow/services/database/models/transactions/model.py (2)
  • TransactionLogsResponse (86-107)
  • TransactionTable (76-78)
src/frontend/src/modals/flowLogsModal/index.tsx (1)
src/frontend/src/modals/flowLogsModal/config/flowLogsColumns.tsx (1)
  • createFlowLogsColumns (21-108)
src/frontend/tests/extended/features/flow-logs-modal.spec.ts (2)
src/frontend/tests/utils/await-bootstrap-test.ts (1)
  • awaitBootstrapTest (4-67)
src/frontend/tests/utils/add-custom-component.ts (1)
  • addCustomComponent (3-12)
src/backend/base/langflow/services/database/models/transactions/model.py (1)
src/backend/base/langflow/serialization/serialization.py (3)
  • serialize (253-305)
  • get_max_text_length (31-33)
  • get_max_items_length (37-39)
src/lfx/src/lfx/graph/utils.py (3)
src/lfx/src/lfx/graph/vertex/base.py (1)
  • Vertex (46-837)
src/backend/base/langflow/services/database/models/transactions/crud.py (1)
  • log_transaction (30-75)
src/backend/base/langflow/services/database/models/transactions/model.py (1)
  • TransactionBase (10-73)
src/backend/tests/unit/api/v1/test_transactions.py (2)
src/backend/base/langflow/services/database/models/transactions/crud.py (2)
  • transform_transaction_table (78-83)
  • transform_transaction_table_for_logs (86-92)
src/backend/base/langflow/services/database/models/transactions/model.py (4)
  • TransactionBase (10-73)
  • TransactionLogsResponse (86-107)
  • TransactionReadResponse (81-83)
  • TransactionTable (76-78)
src/backend/base/langflow/api/v1/monitor.py (2)
src/backend/base/langflow/services/database/models/transactions/crud.py (1)
  • transform_transaction_table_for_logs (86-92)
src/backend/base/langflow/services/database/models/transactions/model.py (2)
  • TransactionLogsResponse (86-107)
  • TransactionTable (76-78)
⏰ 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). (65)
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 39/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 48/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 42/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 49/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 47/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 46/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 44/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 40/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 37/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 50/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 41/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 38/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 43/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 45/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 31/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 36/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 33/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 34/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 32/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 35/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 30/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 27/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 28/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 29/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 25/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 19/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 23/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 24/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 22/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 26/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 21/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 20/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 18/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 17/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 15/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 16/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 14/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/50
  • GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/50
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Lint Backend / Run Mypy (3.11)
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Test Docker Images / Test docker images
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • 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 Starter Projects
🔇 Additional comments (7)
src/lfx/src/lfx/graph/vertex/base.py (2)

660-665: LGTM! Transaction error logging properly captures build failures.

The error logging correctly:

  • Checks for flow_id availability before logging
  • Passes the exception message as the error parameter
  • Uses status="error" appropriately

781-784: LGTM! Transaction success logging properly captures successful builds.

The success logging correctly records the completion of the build process with appropriate parameters.

src/backend/base/langflow/services/database/models/transactions/model.py (1)

86-107: LGTM! TransactionLogsResponse model is well-designed for the logs view.

The model correctly:

  • Excludes internal fields (error, flow_id) as documented
  • Applies serialization limits consistently with TransactionBase
  • Configures from_attributes=True for proper ORM conversion
src/backend/tests/unit/api/v1/test_transactions.py (1)

1-228: LGTM! Comprehensive test coverage for transactions functionality.

The test file provides excellent coverage:

  • Model creation and validation (including edge cases like code filtering)
  • Transformer functions for both single items and lists
  • API endpoint authentication, pagination, and validation
  • Response structure verification
src/backend/base/langflow/api/v1/monitor.py (2)

14-15: LGTM! Imports correctly updated for logs functionality.

The imports properly reference the new transformer function and response model for the logs view.


180-198: LGTM! Endpoint correctly refactored to return logs-specific response.

The changes properly:

  • Update the return type to Page[TransactionLogsResponse]
  • Order transactions by timestamp descending for recent-first display
  • Apply the new transform_transaction_table_for_logs transformer
src/frontend/tests/extended/features/flow-logs-modal.spec.ts (1)

5-212: Nice coverage of Flow Logs Modal behaviors

These tests do a good job covering the main flows:

  • Opening the modal and verifying the description.
  • Empty state ("No Data Available").
  • Closing with Escape.
  • Success and error executions reflected in the logs.

They align well with the new logs modal behavior and backend transaction logging and should catch regressions around modal wiring and status badges.

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 15, 2025
@github-actions github-actions bot removed the bug Something isn't working label Dec 15, 2025
@github-actions github-actions bot added the bug Something isn't working label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants