kai-dong123 opened a new issue, #373: URL: https://github.com/apache/hugegraph-ai/issues/373
### 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 `continue`s, 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 `CreateError`s 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
