- 
                Notifications
    You must be signed in to change notification settings 
- Fork 7.9k
          feat: remove code from Transactions to reduce clutter in logs
          #10400
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| WalkthroughThe changes implement filtering of the 'code' key from transaction inputs during object creation and serialization, add corresponding unit and integration tests to verify this behavior, and configure linting rules for the new test package structure. Changes
 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The changes introduce new filtering logic in core transaction handling with corresponding test coverage across multiple test locations. While individual edits are straightforward (key filtering, test assertions), the distributed nature across multiple files and layers (model, unit tests, integration tests) requires separate reasoning for each component. Possibly related PRs
 Suggested labels
 Suggested reviewers
 Pre-merge checks and finishing touches❌ Failed checks (1 error, 2 warnings)
 ✅ Passed checks (4 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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. Comment  | 
| Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@           Coverage Diff           @@
##             main   #10400   +/-   ##
=======================================
  Coverage   35.04%   35.04%           
=======================================
  Files        1468     1468           
  Lines       83328    83328           
  Branches     9592     9592           
=======================================
  Hits        29205    29205           
  Misses      53275    53275           
  Partials      848      848           
 Flags with carried forward coverage won't be shown. Click here to find out more. 
 🚀 New features to boost your workflow:
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
src/backend/base/langflow/tests/services/database/__init__.py (1)
3-3: Remove the trailing comment.The
# Made with Bobcomment appears to be a non-standard marker that doesn't provide documentation value. Consider removing it to keep the codebase clean.src/backend/base/langflow/tests/__init__.py (1)
3-3: Remove the trailing comment.The
# Made with Bobcomment appears to be a non-standard marker that doesn't provide documentation value. Consider removing it to keep the codebase clean.src/backend/base/langflow/tests/services/database/models/transactions/__init__.py (1)
3-3: Remove the trailing comment.The
# Made with Bobcomment appears to be a non-standard marker that doesn't provide documentation value. Consider removing it to keep the codebase clean.src/backend/base/langflow/tests/services/database/models/__init__.py (1)
3-3: Remove the trailing comment.The
# Made with Bobcomment appears to be a non-standard marker that doesn't provide documentation value. Consider removing it to keep the codebase clean.src/backend/base/langflow/services/database/models/transactions/model.py (1)
41-57: Consider updating the docstring to document code filtering.The
serialize_inputsmethod now filters out the 'code' key, but the docstring doesn't mention this behavior. Consider updating it to document this filtering.Apply this diff to update the docstring:
@field_serializer("inputs") def serialize_inputs(self, data) -> dict: - """Serialize the transaction's input data with enforced limits on text length and item count. + """Serialize the transaction's input data with enforced limits on text length and item count. + + The 'code' key is filtered out from the inputs if present to reduce clutter in logs. Parameters: data (dict): The input data to be serialized. Returns: dict: The serialized input data with applied constraints. """src/backend/base/langflow/tests/services/database/models/transactions/test_model.py (2)
92-120: Misleading test name and docstring.The test name
test_code_key_not_saved_to_databaseand docstring claim to test database persistence, but the test never actually saves the transaction to a database. It only verifies in-memory behavior. The actual database persistence test is insrc/backend/tests/unit/test_database.py::test_transaction_excludes_code_key.Consider renaming this test to
test_code_key_removed_from_inputs_during_initializationto accurately reflect what it tests.
122-122: Remove the trailing comment.The
# Made with Bobcomment appears to be a non-standard marker that doesn't provide documentation value. Consider removing it to keep the codebase clean.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
- pyproject.toml(1 hunks)
- src/backend/base/langflow/services/database/models/transactions/model.py(2 hunks)
- src/backend/base/langflow/tests/__init__.py(1 hunks)
- src/backend/base/langflow/tests/services/database/__init__.py(1 hunks)
- src/backend/base/langflow/tests/services/database/models/__init__.py(1 hunks)
- src/backend/base/langflow/tests/services/database/models/transactions/__init__.py(1 hunks)
- src/backend/base/langflow/tests/services/database/models/transactions/test_model.py(1 hunks)
- src/backend/tests/unit/test_database.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
{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/base/langflow/tests/services/database/__init__.py
- src/backend/base/langflow/tests/__init__.py
- src/backend/tests/unit/test_database.py
- src/backend/base/langflow/tests/services/database/models/__init__.py
- src/backend/base/langflow/tests/services/database/models/transactions/test_model.py
- src/backend/base/langflow/tests/services/database/models/transactions/__init__.py
- src/backend/base/langflow/services/database/models/transactions/model.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/test_database.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/test_database.py
src/backend/tests/unit/test_database.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
For database-related tests that may fail in batch runs but pass individually, consider running them sequentially and be aware of this behavior when writing such tests.
Files:
- src/backend/tests/unit/test_database.py
**/{test_*.py,*.test.ts,*.test.tsx}
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
**/{test_*.py,*.test.ts,*.test.tsx}: 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 simpler test doubles when mocks become excessive
Ensure mocks are used only for external dependencies, not core business logic
Recommend integration tests when unit tests become overly mocked
Check that test files follow the project’s naming conventions (backend: test_*.py; frontend: *.test.ts/tsx)
Verify that tests actually exercise the new or changed functionality, not placeholder assertions
Test files should have descriptive test function names explaining what is being tested
Organize tests logically with proper setup and teardown
Include edge cases and error conditions for comprehensive coverage
Verify tests cover both positive (success) and negative (failure) scenarios
Ensure tests are not mere smoke tests; they should validate behavior thoroughly
Ensure tests follow the project’s testing frameworks (pytest for backend, Playwright for frontend)
Files:
- src/backend/tests/unit/test_database.py
- src/backend/base/langflow/tests/services/database/models/transactions/test_model.py
**/test_*.py
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
**/test_*.py: Backend tests must be named test_*.py and use proper pytest structure (fixtures, assertions)
For async backend code, use proper pytest async patterns (e.g., pytest-asyncio)
For API endpoints, include tests for both success and error responses
Files:
- src/backend/tests/unit/test_database.py
- src/backend/base/langflow/tests/services/database/models/transactions/test_model.py
src/backend/base/langflow/services/database/models/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Place database models in src/backend/base/langflow/services/database/models/
Files:
- src/backend/base/langflow/services/database/models/transactions/model.py
🧠 Learnings (1)
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/
Applied to files:
- src/backend/base/langflow/tests/services/database/models/__init__.py
🧬 Code graph analysis (2)
src/backend/tests/unit/test_database.py (4)
src/backend/tests/unit/services/variable/test_service.py (1)
session(23-28)src/backend/tests/conftest.py (2)
active_user(469-503)
flow(556-572)src/backend/base/langflow/services/database/models/transactions/model.py (1)
TransactionTable(72-74)src/backend/base/langflow/services/database/models/flow/model.py (1)
Flow(186-212)
src/backend/base/langflow/tests/services/database/models/transactions/test_model.py (1)
src/backend/base/langflow/services/database/models/transactions/model.py (2)
TransactionBase(10-69)
serialize_inputs(42-57)
⏰ 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). (16)
- 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 4
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Test Starter Templates
- GitHub Check: Update Component Index
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Update Starter Projects
🔇 Additional comments (8)
pyproject.toml (1)
443-449: LGTM!The lint configuration appropriately relaxes test-specific rules (docstrings, magic values, assertions, private access, broad exception catching) for the new test directory, maintaining consistency with the existing test configuration.
src/backend/base/langflow/services/database/models/transactions/model.py (1)
24-30: LGTM! Defensive filtering during initialization.The
__init__method correctly filters the 'code' key from inputs during object creation. The implementation properly:
- Checks for the existence of 'inputs', validates it's a dict, and checks for the 'code' key
- Creates a shallow copy before mutation to avoid side effects
- Uses
pop()to remove the keysrc/backend/base/langflow/tests/services/database/models/transactions/test_model.py (4)
8-29: LGTM! Test validates code key exclusion during serialization.The test correctly verifies that the 'code' key is filtered out when serializing inputs while preserving other parameters.
32-49: LGTM! Good edge case coverage for None inputs.
52-69: LGTM! Good edge case coverage for non-dict inputs.
72-89: LGTM! Good edge case coverage for empty dict inputs.src/backend/tests/unit/test_database.py (2)
2-2: LGTM! Required imports for the new test.
784-823: ****The test is correctly implemented as synchronous. The
sessionfixture is defined in conftest.py as a synchronous fixture usingSession(engine), not an async fixture. While other tests in the file are async, those tests use theclient: AsyncClientfixture for API testing, not thesessionfixture. The test at lines 784-823 appropriately uses the synchronoussessionandactive_userfixtures and does not require async/await syntax. No changes are needed.Likely an incorrect or invalid review comment.
Summary by CodeRabbit
Bug Fixes
Tests