Skip to content

[Bug] load_into_graph drops the whole vertex when one property value mismatches its declared type, then edges fail with a cryptic "Invalid vertex id" #373

Open

Description

@kai-dong123

Summary

When importing LLM-extracted graph data, Commit2Graph.load_into_graph treats a single property value whose type does not match the schema's declared data_type as a whole-vertex failure: it logs "Property type/format 'age' is not correct, skip it & need check it again" and then continues, silently dropping the vertex. Any edge that references that vertex is then sent to the server with the local reference ("1:Sarah") as an endpoint id and fails with Server Exception: Invalid vertex id '1:Sarah'. The log message says "skip it" (the property) but the code drops the entire vertex — message and behavior disagree.

Reproduction (headless)

  1. Schema without propertykeys (CheckSchema then defaults every property to TEXT): person with primary_keys=["name"], properties=["name","age","occupation"], nullable_keys=["age","occupation"], id_strategy="PRIMARY_KEY"; edge roommate (person→person, property date).
  2. Extraction returns a person with "age":30 (JSON number — the demo prompt contract itself declares age as INT) plus a roommate edge whose outV="1:Sarah".
  3. Import: age: 30 (int) fails the TEXT check → Sarah's vertex is skipped → vid_mapping has no "1:Sarah" → the edge falls back to the raw id → server returns Invalid vertex id '1:Sarah'.

The identical defect appears with a correct typed schema when an LLM returns age:"30" (string) for an INT property — numeric-string output is very common (see #185).

Proposed behavior

  • Lossless coercion first. A helper coerces a value to the declared data_type/cardinality when lossless: numeric string ↔ number, number → text, scalar → [scalar] for LIST/SET (then each element), strict yyyy-MM-dd for DATE. Unknown/un-coercible values are reported, never silently dropped.
  • Nullable property, un-coercible → drop just that property (warning) and keep creating the vertex.
  • Primary-key / non-nullable property missing or un-coercible → skip that vertex with a reason, and skip the edges that reference it — both named in the summary.
  • Edge endpoints: never call addEdge with an id that was not produced by a successful addVertex.
  • Raise only if no vertex could be imported at all (otherwise: partial import + clear summary).

Extended Scope

The same coercion and validation logic should ideally be applied to Edge properties, which are susceptible to the exact same LLM hallucination issues as Vertex properties. Furthermore, to prevent a single hallucinated entity from crashing a batch operation, PK mismatch should gracefully skip the entity rather than raising a fatal exception. Edge properties are currently passed to the server with no type check, and server CreateErrors are swallowed by _handle_graph_creation, so bad edges are silently lost today.

Observability

Vertices and edges should go through the same coercion + reporting helper so diagnostics are aligned. Collect dropped_properties / skipped_vertices / skipped_edges with per-item reasons (scope, item id, label, property, expected, actual, action), attach the summary to the import result, and surface it in the demo (related: #247).

Tests

The in-file FIXME at hugegraph-llm/src/tests/operators/hugegraph_op/test_commit_to_hugegraph_load_into_graph.py:29 already requests this coverage: vertex nullable/primary/collection/date branches, edge-property coercion, edge-skip when an endpoint is missing, and the aggregated summary. Unit tests use a mock client.

I can submit a PR with the fix and tests.

Activity

  1. KHARSHAVARDHAN-eng commented on Sep 16, 2026

    @KHARSHAVARDHAN-eng

    Hi @kai-dong123 , I’d like to work on this issue.

    I’ll investigate the current Commit2Graph.load_into_graph flow, implement the proposed type-coercion and validation handling, ensure invalid vertices/edges are handled safely, and add the corresponding regression tests.

    I’ll start by reviewing the existing implementation and test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions