Skip to content

Fix: Flatten results from update_community calls#1085

Closed
ZLBillShaw wants to merge 1 commit into
getzep:mainfrom
ZLBillShaw:fix/update-communities-unpack-error
Closed

Fix: Flatten results from update_community calls#1085
ZLBillShaw wants to merge 1 commit into
getzep:mainfrom
ZLBillShaw:fix/update-communities-unpack-error

Conversation

@ZLBillShaw

Copy link
Copy Markdown

Summary

Fixed ValueError when update_communities=True is passed to add_episode(). The bug was caused by incorrect unpacking of semaphore_gather results, which returns a list of tuples rather than a single tuple.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Documentation/Tests

Objective

Fix the ValueError: not enough values to unpack (expected 2, got 1) error that occurs when calling add_episode() with update_communities=True.

Root Cause:
In graphiti.py lines 781-787, the code attempts to directly unpack semaphore_gather results:

communities, community_edges = await semaphore_gather(
    *[update_community(self.driver, self.llm_client, self.embedder, node) for node in nodes],
    max_coroutines=self.max_coroutines,
)

However, semaphore_gather returns a list of tuples, not a single tuple:
[(communities, edges), (communities, edges), ...]

- Fixed ValueError when update_communities=True
- semaphore_gather returns a list of tuples, not a single tuple
- Added proper unpacking and flattening logic
- Bug was introduced in commit dcc9da3

Resolves issue where update_communities parameter would fail with:
'ValueError: not enough values to unpack (expected 2, got 1)'
@danielchalef

danielchalef commented Nov 27, 2025

Copy link
Copy Markdown
Member

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ZLBillShaw

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

danielchalef added a commit that referenced this pull request Nov 27, 2025
david-morales added a commit to david-morales/graphiti that referenced this pull request Feb 7, 2026
)

semaphore_gather returns a list of tuples (one per node), not a single
tuple.  Direct destructuring only worked for exactly 1 node and crashed
or silently produced wrong types for 0 or 2+ nodes.  Replace with a
loop that extends the flat community/edge lists from each result.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
MrBlackSheep91 pushed a commit to MrBlackSheep91/graphiti-worker-fix that referenced this pull request Apr 5, 2026
@danielchalef

Copy link
Copy Markdown
Member

Thanks for catching this early — the update_community flatten bug in add_episode. It's now being landed via #1486 (same fix + regression test, rebased on main). Closing as superseded by #1486.

@zep-cla-assistant zep-cla-assistant Bot locked and limited conversation to collaborators Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants