Skip to content

Conversation

@parmar-abhinav
Copy link
Contributor

@parmar-abhinav parmar-abhinav commented Nov 17, 2025

Problem

Entity descriptions with apostrophes (e.g., "The team's first quarter goal") cause Cypher syntax errors and prevent know knowledge graph creation.

Solution

Added character escaping in 'Entity.to_graph_query()`:

Escape \, ', " characters before building Cypher query

Escaping is only for query syntax data stored in database is unchanged

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where entity descriptions containing special characters (backslashes and quotes) would cause errors in graph queries. These characters are now properly handled to ensure reliable query generation.

Prevents syntax errors when descriptions contain quotes or backslashes.

The escaping only affects query generation stored data remains unchanged
@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

The to_graph_query method in graphrag_sdk/entity.py now escapes special characters (backslashes, single quotes, and double quotes) in entity descriptions before embedding them into non-unique attributes to prevent Cypher query syntax errors.

Changes

Cohort / File(s) Summary
Cypher query escaping
graphrag_sdk/entity.py
Entity descriptions are now escaped in to_graph_query method to prevent Cypher syntax errors by sanitizing backslashes, single quotes, and double quotes

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review the escaping logic to verify all necessary special characters are handled correctly
  • Confirm the escaping is applied at the right point in the query construction
  • Check for edge cases (empty descriptions, already-escaped content)

Poem

🐰 Hoppy days! No more syntax frights,
Special chars are now polite,
Quotes and slashes, neat and tight,
Cypher queries shine so bright! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: escaping special characters in entity descriptions to prevent Cypher syntax errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce1c8c and 97ec7a6.

📒 Files selected for processing (1)
  • graphrag_sdk/entity.py (1 hunks)

@galshubeli galshubeli merged commit 3a0aa5a into FalkorDB:main Jan 15, 2026
2 of 3 checks passed
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.

2 participants