Skip to content

Commit aeb354a

Browse files
committed
fix(schema): enforce strict validation when converting property key values
The `convValue` method now utilizes `validValueOrThrow` to ensure that any value which cannot be successfully normalized to the PropertyKey's declared data type will explicitly throw an exception. This prevents silent type mismatches or unexpected behavior and reinforces type safety when handling property values, especially after deserialization.
1 parent 14fa3e3 commit aeb354a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema
  • hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public Object defaultValue() {
130130
// value (e.g. Date) comes back as a String. Normalize it to the
131131
// runtime type expected by this property key's data type. Idempotent
132132
// for values already of the expected type.
133-
Object normalized = this.validValue(value);
133+
Object normalized = this.validValueOrThrow(value);
134134

135135
// For SET cardinality, ensure we return a Set container and collapse duplicates
136136
if (this.cardinality == Cardinality.SET && normalized instanceof Collection) {

hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public Object defaultValue() {
135135
// value (e.g. Date) comes back as a String. Normalize it to the
136136
// runtime type expected by this property key's data type. Idempotent
137137
// for values already of the expected type.
138-
Object normalized = this.validValue(value);
138+
Object normalized = this.validValueOrThrow(value);
139139

140140
// For SET cardinality, ensure we return a Set container and collapse duplicates
141141
if (this.cardinality == Cardinality.SET && normalized instanceof Collection) {

0 commit comments

Comments
 (0)