fix: unpack community results from semaphore_gather in add_episode#1486
fix: unpack community results from semaphore_gather in add_episode#1486just-jeb wants to merge 3 commits into
Conversation
|
I have read the CLA Document and I hereby sign the CLA |
When update_communities=True, semaphore_gather returns a list of
(communities, edges) tuples — one per extracted node. The previous
code tried to unpack this list directly as two values:
communities, community_edges = await semaphore_gather(...)
This raises ValueError: not enough values to unpack (expected 2, got N)
for any episode that extracts at least one node.
Fix: collect the results list, then flatten into the two expected lists.
0ebdd0b to
ef3ae46
Compare
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: [email protected] or I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: [email protected] Signature is valid for 6 months. This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot. |
|
Maintainer note: rebased this onto current main (the fix still applies cleanly at |
The test file had two module-level docstrings; ruff parses the second as a statement, demoting the imports below it (6x E402). Merge them into one docstring and drop the unused AsyncMock/patch imports (F401). No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes a
ValueError: not enough values to unpack (expected 2, got N)crash inadd_episodewhenupdate_communities=True.Type of Change
Objective
semaphore_gatherreturns a list of results — one(communities, edges)tuple per coroutine (one per extracted node). The previous code tried to unpack that list directly as two variables:This raises
ValueError: not enough values to unpack (expected 2, got N)for any episode that extracts at least one node, makingadd_episodewithupdate_communities=Trueentirely broken.Fix: collect into a results list, then flatten:
Testing
tests/test_community_update_unpack.py)Two unit tests:
test_semaphore_gather_community_results_flatten— verifies the fixed flatten logic correctly collects communities and edges across multiple nodestest_semaphore_gather_unpack_raises_without_fix— demonstrates the old pattern raisesValueError, confirming the bug existedBreaking Changes
Checklist
make lintpasses)Related Issues
Reproduces on
graphiti-core==0.29.0. Verified fix locally.