Skip to content

Conversation

gajazlikovac
Copy link
Contributor

@gajazlikovac gajazlikovac commented Jun 23, 2025

Description

Cypher code was breaking if "-" was in the name of relation. Same with non-ASCII characters.
Added simple sanitiser for relationship and node names.
New node and relation names follow neo4j convention (UPPERCASE and PascalCase, respectively)

Fixes #3020

Type of change

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

How Has This Been Tested?

Manually tested. Try imputing the prompts form the issue above and log the results. :)

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
  • 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
  • I have checked my code and corrected any misspellings

Maintainer Checklist

@CLAassistant
Copy link

CLAassistant commented Jun 23, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@akshat1423 akshat1423 left a comment

Choose a reason for hiding this comment

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

Hey! Thanks for your contribution.

I have noticed that the _remove_spaces_from_entities function now includes additional sanitization logic like title-casing node labels and upper-casing relationships (via _sanitize_node_label and _sanitize_relationship_type).

This introduces a few concerns:

Breaking change risk: We currently store and match entity names using lowercase with underscores (e.g., customer_account). Changing this format might cause entity mismatches or duplicate nodes in Neo4j.

Inconsistent mapping: The entity_type_map and various Cypher queries assume the previous normalized format, and updating one side without the other could lead to silent failures.

Would you mind reverting to the original space-to-underscore normalization for now and possibly exploring a safer transition plan separately?

@gajazlikovac
Copy link
Contributor Author

Hey @akshat1423,
I did not know that. Thanks for the info. I will ignore the neo4j naming convention for now.
This means the the pr will include only one sanitiser function, to get rid of hyphens and non-ASCII chars.

The space to _ will stay.

You can expect the the new pr soon.
Thanks,
Stefan

@gajazlikovac gajazlikovac requested a review from akshat1423 June 25, 2025 13:17
Copy link
Contributor

@parshvadaftari parshvadaftari left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for the contributions.

@prateekchhikara prateekchhikara merged commit dbe909c into mem0ai:main Aug 12, 2025
2 of 3 checks passed
thestumonkey pushed a commit to thestumonkey/mem0 that referenced this pull request Sep 7, 2025
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.

Relation contains hyphens
5 participants