Skip to content

improve handling invalid entities#565

Merged
nikgraf merged 9 commits intomainfrom
nik/improve-handling-invalid-entities
Dec 6, 2025
Merged

improve handling invalid entities#565
nikgraf merged 9 commits intomainfrom
nik/improve-handling-invalid-entities

Conversation

@nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented Dec 6, 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 pull request improves error handling for invalid entities by collecting and surfacing validation failures instead of throwing errors. The core changes include:

  • Introduced structured error tracking with InvalidEntity and InvalidRelationEntity types that include both raw payload and decode errors
  • Modified findOnePublic to return { entity, invalidEntity, invalidRelationEntities } instead of throwing on validation failures
  • Enhanced findManyPublic and searchManyPublic to collect invalid entities and invalid relation entities
  • Added a logInvalidResults toggle (defaulting to true) at both SDK and React provider levels to control console warning output
  • Updated React hooks to expose invalidEntity and invalidRelationEntities alongside entity data

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/hypergraph/src/utils/convert-relations.ts Core logic to validate relation entities during decoding and collect invalid relations instead of including them in results
packages/hypergraph/src/entity/find-one-public.ts Changed to return structured result with entity/invalidEntity/invalidRelationEntities instead of throwing; added logInvalidResults parameter
packages/hypergraph/src/entity/find-many-public.ts Added InvalidEntity type, enhanced parseResult to track invalid entities and relations, added logInvalidResults parameter
packages/hypergraph/src/entity/search-many-public.ts Updated to return invalidRelationEntities alongside existing fields
packages/hypergraph-react/src/HypergraphAppContext.tsx Added logInvalidResults prop to provider context for global configuration
packages/hypergraph-react/src/hooks/use-entity.tsx Enhanced to accept and propagate logInvalidResults, returns invalidEntity and invalidRelationEntities
packages/hypergraph-react/src/hooks/use-entities.tsx Enhanced to accept and propagate logInvalidResults parameter
packages/hypergraph-react/src/hooks/use-entities-public-infinite.ts Added logInvalidResults parameter support
packages/hypergraph-react/src/internal/use-entity-public.tsx Updated to destructure and return invalidEntity and invalidRelationEntities from findOnePublic result
packages/hypergraph-react/src/internal/use-entity-private.tsx Updated type definition to use Entity.InvalidEntity
packages/hypergraph-react/src/internal/use-entities-public.tsx Added logInvalidResults parameter and returns invalidRelationEntities
packages/hypergraph/test/entity/find-one-public.test.ts New comprehensive tests for invalid entity and invalid relation entity handling
packages/hypergraph/test/entity/find-many-public.test.ts New tests for parseResult with invalid entities and relations
packages/hypergraph-react/test/HypergraphSpaceContext.test.tsx Updated tests to use waitFor for proper async assertion timing
packages/hypergraph-react/test/HypergraphAppContext.test.tsx Replaced setTimeout with waitFor for more reliable test assertions
packages/hypergraph-react/vitest.config.ts Added explicit test file patterns and exclusions
docs/docs/query-public-data.md Updated documentation to describe invalidEntities and invalidRelationEntities return values
docs/docs/query-private-data.md Updated documentation to clarify invalidEntities structure
apps/events/src/routes/podcasts.lazy.tsx Uncommented example code demonstrating usage of invalidEntity and invalidRelationEntities
.changeset/*.md Added changesets documenting the breaking and feature changes

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

nikgraf and others added 2 commits December 6, 2025 14:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nikgraf nikgraf merged commit 56f49c4 into main Dec 6, 2025
6 checks passed
@nikgraf nikgraf deleted the nik/improve-handling-invalid-entities branch December 6, 2025 13:47
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