Skip to content

Fix missing commas in Kuzu graph INSERT queries #3358

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Padarn
Copy link

@Padarn Padarn commented Aug 23, 2025

Description

Fixed two missing commas in the Kuzu memory graph insertion queries:

  1. Missing comma after source.mentions = 1 in ON CREATE SET clause (line 526)
  2. Missing comma after source.mentions = coalesce(source.mentions, 0) + 1 in ON MATCH SET clause (line 529)

These syntax errors caused Kuzu parser exceptions when inserting entities with embeddings where the destination node exists but the source node is new.
Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I've added a unit test to the change

Please delete options that are not relevant.

  • Unit Test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [x I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • [ x I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@CLAassistant
Copy link

CLAassistant commented Aug 23, 2025

CLA assistant check
All committers have signed the CLA.

@parshvadaftari
Copy link
Contributor

@Padarn Can you please sign the CLA?

@@ -78,6 +79,32 @@ def test_kuzu_memory_initialization(
assert kuzu_memory.llm == mock_llm
assert kuzu_memory.threshold == 0.7

@patch("mem0.memory.kuzu_memory.EmbedderFactory")
@patch("mem0.memory.kuzu_memory.LlmFactory")
def test_kuzu_missing_comma_bug_scenario(self, mock_llm_factory, mock_embedder_factory, mock_config, mock_embedding_model, mock_llm):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks sorry I was testing this locally to make sure it was fixed, this can be removed

@Padarn Padarn force-pushed the fix-kuzu-comma-bug branch from 5558523 to 4448208 Compare August 23, 2025 09:25
@Padarn Padarn force-pushed the fix-kuzu-comma-bug branch from 4448208 to 1400eeb Compare August 23, 2025 09:31
@@ -109,12 +111,21 @@ def test_kuzu(self, mock_llm_factory, mock_embedder_factory, mock_config, mock_e
assert get_node_count(kuzu_memory) == 3
assert get_edge_count(kuzu_memory) == 4

data3 = [
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests for scenario which bug was found in

@parshvadaftari
Copy link
Contributor

Can you also provide me how to recreate this issue?

@Padarn
Copy link
Author

Padarn commented Aug 24, 2025

If you run the unit test without the fix then you will get the error:

from my branch

git checkout main -- mem0/memory/kuzu_memory.py
python -m pytest tests/memory/test_kuzu.py::TestKuzu::test_kuzu -v

error

          RuntimeError: Parser exception: Invalid input <
                              source>: expected rule ku_Statements (line: 9, offset: 20)
          "                    source.embedding = CAST($source_embedding,'FLOAT[384]')"
                               ^^^^^^

test_env/lib/python3.13/site-packages/kuzu/connection.py:134: RuntimeError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants