Schema sync persists duplicate vertex type configs for multi-label vertices
- Dominant language
- TypeScript
- Stars
- 481
- Forks
- 108
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 5
Description
## Description
The initial schema sync persists duplicate vertex type configs for multi-label vertices, whereas the incremental update path merges them by type. The two paths disagree, and the duplicates are written to IndexedDB.
## Root cause
`mapVertexToTypeConfigs` (`core/StateProvider/schema.ts`) returns one `VertexTypeConfig` per label: `vertex.types.map(type => …)`. A node with labels `[A, B]` yields a config for A and a config for B.
During schema sync, `fetchVerticesAttributes` pushes every sampled node's configs into the result array with no dedup. So a multi-label node — or two different sampled nodes that share a label — produces duplicate `type` entries in `SchemaResponse.vertices`.
The write path `replaceSchemaAtom` (`connector/queries/schemaSyncQuery.ts`) then persists `...schema` verbatim, so the duplicates land in storage.
By contrast the incremental path, `updateSchemaFromEntities` → `mergeVertices` (`core/StateProvider/schema.ts`), merges by type: `const byType = new Map(existing.map(v => [v.type, v]))`. Same-typed configs are collapsed and their attributes merged. The initial sync should produce the same deduped shape.
## Scope
- Vertex-specific. Edges each carry a single `~type`, so `mapEdgeToTypeConfig` returns one config and no duplication arises.
- Connector-agnostic: both the openCypher and Gremlin `fetchVerticesAttributes` exhibit it. Pre-existing — surfaced while reviewing the openCypher schema-sync batching change (#2076), not introduced by it.
## Suggested fix
Merge vertex type configs by type on the sync write path so the persisted schema matches what `mergeVertices` produces for incremental updates — ideally reusing the existing merge-by-type logic rather than a separate dedup. Merging (not just de-duping) matters because two samples of the same label can contribute different attributes.
## Related Issues
- Surfaced from #2076
> [!IMPORTANT]
> Internal only — this issue is maintained by the core team and is not accepting external contributions.
Contributor guide
Research direction
Start in core/StateProvider/schema.ts with mapVertexToTypeConfigs, fetchVerticesAttributes, and the existing mergeVertices logic, then inspect connector/queries/schemaSyncQuery.ts and replaceSchemaAtom. Make initial schema sync merge same-type vertex configs and their attributes so SchemaResponse.vertices and persisted IndexedDB data contain one config per type, matching incremental updates; edges and both connectors should remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100