You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "dpol1 (via GitHub)" <gi...@apache.org> on 2026/05/15 10:25:04 UTC
[I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
dpol1 opened a new issue, #3028:
URL: https://github.com/apache/hugegraph/issues/3028
### Bug Type (问题类型)
logic (逻辑设计问题)
### Before submit
- [x] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
### Environment (环境信息)
- Server Version: 1.7.0
- Backend: schema metadata reload paths; not backend-specific
- OS: N/A
- Data Size: N/A
### Expected & Actual behavior (期望与实际表现)
### Expected
`Userdata.DEFAULT_VALUE` (`~default_value`) should preserve the expected runtime type after schema metadata is serialized and reloaded.
For example, a `PropertyKey` with `DataType.DATE` should reload its default value as `java.util.Date`, not as a generic JSON `String`.
### Actual
Schema userdata is deserialized through raw `Map` / `Object` paths, so Jackson cannot infer the original runtime type.
For `~default_value`, a `Date` default value can be serialized as a formatted string and later reloaded as `String`.
This may affect multiple schema reload paths, including:
- `SchemaMetaManager -> PropertyKey.fromMap(...)`
- JSON-based backend serializers such as Text/Binary/Table/Cassandra-style userdata reload paths
- the mirror userdata model in `hugegraph-struct`
### Possible fix direction
`PropertyKey` already knows its `dataType`, so `~default_value` could be normalized after the `PropertyKey` is reconstructed, using the same conversion logic already used for property values.
### Scope
- Investigate `Userdata.DEFAULT_VALUE` reload behavior, especially for `DataType.DATE`.
- Normalize confirmed typed default values after schema reload.
- Check whether the same gap exists in `hugegraph-struct`.
- Add regression tests for the confirmed reload path(s).
### Vertex/Edge example (问题点 / 边数据举例)
```javascript
```
### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
```javascript
```
--
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: dev-unsubscribe@hugegraph.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
Posted by "dpol1 (via GitHub)" <gi...@apache.org>.
dpol1 commented on issue #3028:
URL: https://github.com/apache/hugegraph/issues/3028#issuecomment-4459026850
@dosubot could you check whether this issue is a valid follow-up for typed userdata reload handling, especially `Userdata.DEFAULT_VALUE` and `hugegraph-struct`?
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
Posted by "dpol1 (via GitHub)" <gi...@apache.org>.
dpol1 commented on issue #3028:
URL: https://github.com/apache/hugegraph/issues/3028#issuecomment-4459669492
@dosubot What exact role does `hugegraph-struct`'s `PropertyKey` / `Userdata` model play in schema serialization or RPC flows, and should the `DEFAULT_VALUE` normalization be duplicated there or kept only server-side?
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #3028:
URL: https://github.com/apache/hugegraph/issues/3028#issuecomment-4459082064
<!-- Answer -->
Yes, this is a valid follow-up issue. Here's why:
**The gap is real.** `Userdata.DEFAULT_VALUE` (`~default_value`) is defined in both `hugegraph-core` [[1]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/Userdata.java#L31) and `hugegraph-struct` [[2]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/Userdata.java#L31). `PropertyKey` stores default values in the userdata map via `defineDefaultValue()` / `defaultValue()` [[3]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java#L119-L124), and `PropertyKey.fromMap()` deserializes userdata — including `~default_value` — as raw `Map<String, Object>` [[4]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/huge
graph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java#L443-L483). This means a `DataType.DATE` default value will be reloaded as a `String`, exactly the same root cause as the `~create_time` bug in [#3013](https://github.com/apache/hugegraph/issues/3013#issuecomment-4380310057) [[5]](https://github.com/apache/hugegraph/issues/3013#issuecomment-4380310057).
**Relationship to #3013.** Issue #3013 established that all backend serializers deserialize userdata into a raw `Map`, so formatted timestamps are never converted back to `Date`. The fix direction discussed there (normalizing in `SchemaElement.userdata(String, Object)`) would naturally cover `~create_time` but would **not** cover `~default_value`, because `~default_value`'s expected type depends on `PropertyKey.dataType()` rather than being unconditionally `Date`. That makes this a distinct follow-up requiring its own type-aware normalization step — likely in `PropertyKey.fromMap()` or `PropertyKey.defaultValue()` after the data type is known.
**hugegraph-struct scope.** The `hugegraph-struct` module has its own parallel `Userdata` and `PropertyKey` classes [[6]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/Userdata.java) [[7]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L124-L129) used for distributed RPC communication [[8]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/README.md#L5). If `hugegraph-struct`'s `PropertyKey` also deserializes from maps or JSON without type-aware normalization, the same gap would exist there as well.
**Summary:** This is a valid, distinct follow-up to #3013 — same class of bug (userdata type loss on reload), but requires a different fix because the expected type of `~default_value` is dynamic (driven by `dataType`) rather than static.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).*
---
Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fhugegraph).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fhugegraph&message_id=969f5cdd-5dfb-489b-95c8-ad31c7f2ab2b) [](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fhugegraph) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fhugegraph)
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #3028:
URL: https://github.com/apache/hugegraph/issues/3028#issuecomment-4459779067
<!-- Answer -->
Good question. Here's what `hugegraph-struct`'s `PropertyKey` / `Userdata` actually does and where normalization should live:
**Role in the architecture:** `hugegraph-struct`'s `PropertyKey` is used by **hugegraph-store** (the distributed storage layer) to reconstruct schema metadata retrieved from hugegraph-pd. Schema elements are not protobuf messages — they flow as **JSON** through PD's generic KV service [[1]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/managers/SchemaMetaManager.java#L73-L122). The store deserializes them via `PropertyKey.fromMap()` [[2]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L591-L627) and then uses the reconstructed `PropertyKey` as a **codec descriptor** to guide binary encoding/decoding of property *values* in RocksDB [[3]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apach
e/hugegraph/serializer/BytesBuffer.java#L553-L563).
**The conversion path:**
```
hugegraph-core PropertyKey → asMap() → JSON → PD KV store
↓
hugegraph-struct PropertyKey ← fromMap() ← JSON ← PD retrieval
```
There is no direct converter between the two `PropertyKey` classes — conversion is implicit through JSON [[4]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L567-L627). This is the exact point where type information is lost: `fromMap()` stores userdata values as-is from the deserialized `Map<String, Object>`, with no type-aware normalization [[5]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L610-L613).
**Where normalization is needed:** Both sides need it, but for different reasons:
1. **hugegraph-core** (server-side): Needed when the server itself reloads schema from backend storage or PD after cache invalidation. The existing serializers (Text/Binary/MySQL/Cassandra) all deserialize userdata into raw maps [[6]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java#L1230-L1245). This is the same path that causes the `~create_time` issue in #3013.
2. **hugegraph-struct** (store-side): Needed because `PropertyKey.fromMap()` reconstructs from JSON with no type conversion on userdata [[7]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L122-L130). If the store ever calls `defaultValue()` and uses the result — for example to fill missing property values during binary encoding — it would get a raw `String` instead of the expected typed value.
**Recommendation:** The normalization should exist in **both** modules, ideally as a shared pattern. The natural location is in `PropertyKey.defaultValue()` itself (or immediately after `fromMap()` sets the data type), since that's where `dataType` is known and can drive the conversion. The struct version already has `validValue()` / `convValue()` methods that do type conversion [[8]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java#L289-L297) — those could be reused:
```java
public Object defaultValue() {
Object val = this.userdata().get(Userdata.DEFAULT_VALUE);
if (val != null) {
val = this.validValue(val); // normalize using dataType
}
return val;
}
```
This avoids duplicating conversion logic and keeps both modules consistent. Since the two `PropertyKey` classes have nearly identical implementations, the same fix pattern applies to both [[9]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java) [[10]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-struct/src/main/java/org/apache/hugegraph/struct/schema/PropertyKey.java).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).*
---
Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fhugegraph).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fhugegraph&message_id=1feade92-61dd-43db-927e-c2491d86fd50) [](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fhugegraph) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fhugegraph)
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin closed issue #3028: [Bug] Preserve typed DEFAULT_VALUE and struct userdata after JSON reload
URL: https://github.com/apache/hugegraph/issues/3028
--
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: dev-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org