Skip to content

fix bug for multiple backlinks with the same property id, but different type targets#573

Merged
nikgraf merged 2 commits intomainfrom
nik/fix-bug
Dec 7, 2025
Merged

fix bug for multiple backlinks with the same property id, but different type targets#573
nikgraf merged 2 commits intomainfrom
nik/fix-bug

Conversation

@nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented Dec 7, 2025

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where multiple backlinks with the same property ID but different target type IDs would collide, causing incorrect data retrieval. The fix introduces target type IDs into the relation alias generation to ensure unique aliases for each relation configuration.

Key Changes

  • Modified getRelationAlias to accept an optional targetTypeIds parameter and incorporate it into the alias through canonicalization
  • Added comprehensive test coverage for the new alias generation logic
  • Updated all call sites to pass targetTypeIds when available
  • Added test entities (PersonHostTest, EpisodeHostTest, PodcastHostTest) to demonstrate the bug scenario

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/hypergraph/src/utils/relation-query-helpers.ts Extended getRelationAlias to include target type IDs in the alias, added helper functions for sanitization and canonicalization
packages/hypergraph/src/utils/convert-relations.ts Updated to pass targetTypeIds when calling getRelationAlias
packages/hypergraph/test/utils/relation-query-helpers.test.ts Added new test file with comprehensive coverage for alias generation logic
packages/hypergraph/test/utils/relation-config-overrides.test.ts Updated to dynamically compute relation alias instead of using hardcoded string
packages/hypergraph/test/entity/find-one-public.test.ts Updated to properly compute relation alias with target type IDs
packages/hypergraph/test/entity/find-many-public.test.ts Updated to properly compute relation alias with target type IDs
apps/events/src/schema.ts Added test schemas demonstrating the bug scenario with duplicate property IDs
apps/events/src/routes/podcasts.lazy.tsx Added example usage of the new test schemas to verify the fix works

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nikgraf nikgraf merged commit 38f70f3 into main Dec 7, 2025
6 checks passed
@nikgraf nikgraf deleted the nik/fix-bug branch December 7, 2025 14:51
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