fix(graph): treat missing frozen cache as cache miss#12495
Conversation
Signed-off-by: suyua9 <1521777066@qq.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughUpdated fallback cache behavior to return Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 3 warnings, 1 inconclusive)
✅ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/backend/tests/unit/graph/test_cache_restoration.py`:
- Around line 242-251: The test currently only calls a local get_cache_func and
doesn't exercise Graph's fallback; update the test to simulate
get_chat_service() being unavailable (e.g., monkeypatch/getattr to raise or
return None) and invoke build_vertex (the real code path that uses
Graph.astep/Graph.process) so the actual fallback cache getter runs; await the
build_vertex call and assert that the cache getter used by build_vertex returns
an instance of CacheMiss() (reference Graph.astep, Graph.process,
get_chat_service, build_vertex, CacheMiss).
🪄 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: 773f9f13-32ea-493e-8750-a46708950aed
📒 Files selected for processing (2)
src/backend/tests/unit/graph/test_cache_restoration.pysrc/lfx/src/lfx/graph/graph/base.py
| @pytest.mark.asyncio | ||
| async def test_service_unavailable_fallback_returns_cache_miss(self): | ||
| """Fallback cache getter should behave like a cache miss, not a cache hit.""" | ||
|
|
||
| async def get_cache_func(*args, **kwargs): # noqa: ARG001 | ||
| return CacheMiss() | ||
|
|
||
| cached_result = await get_cache_func(key="frozen-vertex") | ||
|
|
||
| assert isinstance(cached_result, CacheMiss) |
There was a problem hiding this comment.
Regression test does not exercise the changed Graph fallback path.
This test only checks a locally defined get_cache_func, so it will still pass even if Graph.astep/Graph.process regress back to returning None. Please drive one real execution path with get_chat_service() unavailable and assert the cache getter used by build_vertex yields CacheMiss().
As per coding guidelines: "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".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/backend/tests/unit/graph/test_cache_restoration.py` around lines 242 -
251, The test currently only calls a local get_cache_func and doesn't exercise
Graph's fallback; update the test to simulate get_chat_service() being
unavailable (e.g., monkeypatch/getattr to raise or return None) and invoke
build_vertex (the real code path that uses Graph.astep/Graph.process) so the
actual fallback cache getter runs; await the build_vertex call and assert that
the cache getter used by build_vertex returns an instance of CacheMiss()
(reference Graph.astep, Graph.process, get_chat_service, build_vertex,
CacheMiss).
|
Follow-up update: I addressed the CodeRabbit test-coverage concern in the latest push (aaddf96). The regression test now drives the real |
Summary
CacheMiss()from the fallback frozen-cache getter when the chat service is unavailableTesting
python3 -m py_compile src/lfx/src/lfx/graph/graph/base.py src/backend/tests/unit/graph/test_cache_restoration.pygit diff --checkpytest src/backend/tests/unit/graph/test_cache_restoration.py -q(pytestis not installed in this environment)Closes #12408
Summary by CodeRabbit
Bug Fixes
Tests