fix(schema): raise a clear error for duplicate relationship types#535
Open
NathalieCharbel wants to merge 2 commits into
Open
fix(schema): raise a clear error for duplicate relationship types#535NathalieCharbel wants to merge 2 commits into
NathalieCharbel wants to merge 2 commits into
Conversation
15 tasks
fb71886 to
8fc47af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improves the
SchemaValidationErrorraised for graph schemas that define the same relationship-type label more than once inrelationship_typeswith different properties and constraints.e.g.
Currently, on schema validation, duplicate relationship-type labels are silently collapsed by last-write-wins lookup index. When a constraint then references a property that lived on the shadowed (overwritten) duplicate, validation fails with a misleading error that listed the surviving entry's properties as the only "valid" ones
This is incorrect on two counts: the property does exist (on the other duplicate), and - per Neo4j semantics - a relationship type is global per name, so two entries with the same label and different definitions are an invalid model in the first place.
GraphSchemanow detects duplicaterelationship_typeslabels up front and raises a clear, actionableSchemaValidationErrorthat names the duplicated label, its property sets, the underlying Neo4j rule, and a suggestion to fix it. The check runs before constraint validation, so the clear duplicate-label error replaces the old misleading one.This path intended for user-provided schema (where users should be informed about what's going wrong with their provided model). Follow-up PRs will handle the LLM schema-generation path, where the prompt will be slightly tuned to avoid having that + a post extraction validation step to reconcile automatically duplicate relationship types.
Type of Change
Complexity
Complexity: Low
How Has This Been Tested?
Checklist
The following requirements should have been met (depending on the changes in the branch):