You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "imbajin (via GitHub)" <gi...@apache.org> on 2026/10/04 17:00:40 UTC
[PR] fix(client): prepare legacy graph compatibility [hugegraph-toolchain]
imbajin opened a new pull request, #776:
URL: https://github.com/apache/hugegraph-toolchain/pull/776
## Purpose of the PR
Legacy servers return graph configuration as JSON text, while newer APIs use Properties. Normalize that configuration for create/clone requests so the Client retains Server 1.5 compatibility. A legacy clone without configuration now sends an empty entity instead of the literal text null.
Original preparation and review: https://github.com/hugegraph/hugegraph-toolchain/pull/41.
Depends on https://github.com/apache/hugegraph-toolchain/pull/775. Merge the shared build preparation first. This PR targets master and currently includes prerequisite changes; after the prerequisite lands, rebase this same organization branch onto the updated upstream base and revalidate the module diff before merging.
## Main Changes
- Convert supported legacy configuration values and reject null or nested values explicitly.
- Preserve create/clone request encoding and verify the real legacy HTTP route and empty clone body.
- Update task/target tests for their current cancellation and URL contracts.
- Retain the existing bytecode baseline and runtime dependency versions.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage.
- [x] Already covered by Client unit tests and Checkstyle.
- [x] Need tests and can be verified as follows:
- JDK 11 preparation validation used hash-verified released dependencies.
- The latest graph configuration/request regressions passed on native Java 17, including a real loopback HTTP request.
- Current-head organization CI is still running/queued; upstream checks will run separately.
## Does this PR potentially affect the following parts?
- [ ] Nope
- [ ] Dependencies (build/test tooling only; runtime payload is unchanged by this preparation)
- [x] Modify configurations (CI/test configuration)
- [x] The public API (compatible behavior; signatures unchanged)
- [x] Other affects: tests and validation tooling
## Documentation Status
- [ ] Doc - TODO
- [x] Doc - Done
- [ ] Doc - No Need
--
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: [PR] fix(client): prepare legacy graph compatibility [hugegraph-toolchain]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #776:
URL: https://github.com/apache/hugegraph-toolchain/pull/776#issuecomment-5982493743
## [Codecov](https://app.codecov.io/gh/apache/hugegraph-toolchain/pull/776?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 51.61%. Comparing base ([`b066b80`](https://app.codecov.io/gh/apache/hugegraph-toolchain/commit/b066b805630ca591809cfee2da2aae1395fc6b42?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`12f6988`](https://app.codecov.io/gh/apache/hugegraph-toolchain/commit/12f69888387c6381249f8c2c277936d41d274b91?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 244 commits behind head on master.
> :exclamation: There is a different number of reports uploaded between BASE (b066b80) and HEAD (12f6988). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (b066b80) | HEAD (12f6988) |
>|------|------|------|
>||2|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #776 +/- ##
=============================================
- Coverage 62.49% 51.61% -10.89%
+ Complexity 1903 975 -928
=============================================
Files 262 111 -151
Lines 9541 5880 -3661
Branches 886 756 -130
=============================================
- Hits 5963 3035 -2928
+ Misses 3190 2583 -607
+ Partials 388 262 -126
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/hugegraph-toolchain/pull/776?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: [PR] fix(client): prepare legacy graph compatibility [hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #776:
URL: https://github.com/apache/hugegraph-toolchain/pull/776
--
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: [PR] fix(client): prepare legacy graph compatibility [hugegraph-toolchain]
Posted by "bitflicker64 (via GitHub)" <gi...@apache.org>.
bitflicker64 commented on code in PR #776:
URL: https://github.com/apache/hugegraph-toolchain/pull/776#discussion_r4183173098
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -86,6 +99,43 @@ public Map<String, String> create(String name, String cloneGraphName, String con
return result.readObject(Map.class);
}
+ private static String legacyGraphConfig(String configText) {
+ Map<?, ?> config = JsonUtil.fromJson(configText, Map.class);
+ Properties properties = new Properties();
+ config.forEach((key, value) -> {
+ E.checkArgument(value instanceof String || value instanceof Number ||
+ value instanceof Boolean,
+ "Legacy graph config option '%s' must be a scalar value", key);
+ properties.setProperty(key.toString(), value.toString());
+ });
+ StringWriter text = new StringWriter();
+ try {
+ properties.store(text, null);
Review Comment:
Important: Non-ASCII config values are corrupted on any client JVM whose default charset is not UTF-8. `Properties.store(Writer, ...)` does not escape characters above `\u007E` (only the `OutputStream` overload does), so a value such as `李四` stays raw in `configText`. hugegraph-common's `AbstractRestClient.buildRequestBody` then sends it as `bodyContent.getBytes()`, which uses the platform charset, under `Content-Type: text/plain` with no charset parameter. Jersey on the 1.5 server decodes a charset-less `text/plain` String as UTF-8. On JDK 8 to 17 with a Windows-1252 or GBK default, the server stores the wrong password or path, with no error. Reproduced on JDK 17: `"jdbc.password=李四é".getBytes()` under `-Dfile.encoding=windows-1252`, decoded as UTF-8, gives `jdbc.password=???`. `testLegacyConfigPreservesWhitespaceWithServerParser` does not catch this because it parses the Java String and never encodes it to bytes.
The loop below already rewrites the stored text, so it can make the body pure ASCII. Commons Configuration decodes `\uXXXX`, and surrogate pairs come back intact because each half is escaped separately:
```java
} else if (c == ' ') {
encoded.append("\\u0020");
} else if (c > 0x7E) {
encoded.append(String.format("\\u%04x", (int) c));
} else {
encoded.append(c);
}
```
Please also add an assertion that the converted body is ASCII-only, for example `StandardCharsets.US_ASCII.newEncoder().canEncode(body)`, so the charset independence is tested.
--
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: [PR] fix(client): prepare legacy graph compatibility [hugegraph-toolchain]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #776:
URL: https://github.com/apache/hugegraph-toolchain/pull/776#discussion_r4184554268
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -86,6 +99,43 @@ public Map<String, String> create(String name, String cloneGraphName, String con
return result.readObject(Map.class);
}
+ private static String legacyGraphConfig(String configText) {
+ Map<?, ?> config = JsonUtil.fromJson(configText, Map.class);
+ Properties properties = new Properties();
+ config.forEach((key, value) -> {
+ E.checkArgument(value instanceof String || value instanceof Number ||
+ value instanceof Boolean,
+ "Legacy graph config option '%s' must be a scalar value", key);
+ properties.setProperty(key.toString(), value.toString());
+ });
+ StringWriter text = new StringWriter();
+ try {
+ properties.store(text, null);
Review Comment:
Fixed in c5a5d6be on the shared source branch (org PR #41). The existing legacy conversion now escapes non-ASCII UTF-16 code units as Unicode sequences, including both surrogate halves, so its request body is ASCII-only. The regression asserts ASCII encoding and checks Chinese, accented characters, emoji, whitespace, and literal escapes after UTF-8, Windows-1252, and GBK byte encoding followed by UTF-8 decoding through Commons Configuration 2.8.0. Native Java 17 GraphsAPITest passed all 10 tests; independent final diff review found no actionable defects. This validates the conversion/parser boundary, without claiming a new Server or MySQL integration run.
--
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