bitflicker64 opened a new pull request, #401: URL: https://github.com/apache/hugegraph-ai/pull/401
## Purpose A scan of `hugegraph-python-client` turned up two small bugs and two contract test files that CI never runs. This PR fixes the bugs, adds the missing marks, and pins the schema builders' write requests with contract tests. It does not change any public signature or request payload. ## Main changes - `VertexLabel.eliminate()` did not reset the builder after sending its request. It was the only append, eliminate or remove method that skipped `clean_parameter_holder()`, so a reused builder sent the eliminated `user_data` again on its next write. It now resets like `PropertyKey.eliminate()` and `EdgeLabel.eliminate()`. The usual `schema().vertex_label(name)...eliminate()` chain gets a new builder each time and does not change. Reusing the same builder object after `eliminate()` now raises `Parameters required`, the same as after any other write. - `_decode_escaped_text()` (used only for the error log in `ResponseValidation`) encoded the body as UTF-8 before decoding it with `unicode_escape`, which reads those bytes as Latin-1. Any failed request whose body contained Chinese text and an escape such as `\n` was logged garbled (`张三` became `å¼ ä¸`). It now encodes with `latin-1` and `backslashreplace`, so non-ASCII text stays intact and ASCII escapes still decode. Return values and raised exceptions do not change. - Removed `_cached_log_file()`, `_determine_buffer_size()`, `LOG_BUFFER_SIZE_ENV` and `DEFAULT_BUFFER_SIZE` from `utils/log.py`. Nothing in the repository calls them, none are in `__all__`, and `_cached_log_file()` returned a file that was already closed. - `test_raw_gremlin_contract.py` and `test_property_cas_contract.py` had no marker, so neither the `unit or contract` job nor the `integration and hugegraph` job selected them. Both now carry `pytestmark = pytest.mark.contract`. They only read the JSON contract fixtures, and the CAS activation gate stays skipped. - New contract tests cover the path, method and payload of `append()`, `eliminate()` and `remove()` for the schema builders, and check that every write resets the builder. The paths are pinned as they are today, including the `/?action=` form that `PropertyKey` and `VertexLabel.eliminate()` use and the `?action=` form used elsewhere. ## Verification Run on Linux with Python 3.14 through uv 0.13.5, at commit `a3bb00d` on top of `apache/main` `a90b1c4`: ```bash uv sync --all-extras uv run --extra dev ruff format --check . # 581 files already formatted uv run --extra dev ruff check . # All checks passed! uv run --extra dev ty check hugegraph-python-client/src/pyhugegraph # All checks passed! uv run pytest hugegraph-python-client/src/tests -m "unit or contract" ``` | Run | Result | |---|---| | `main` | 139 passed, 78 deselected | | This PR | 168 collected: 165 passed, 3 skipped (CAS gate), 70 deselected | | This PR's tests with the production changes reverted | 2 failed, 163 passed | The two failures are the new regression tests, `test_error_log_decodes_escapes_without_garbling_utf8_request_body` and `test_schema_builder_write_clears_parameters[VertexLabel-eliminate]`. The `hugegraph-llm` unit split from `hugegraph-llm/AGENTS.md` (with `SKIP_EXTERNAL_SERVICES=true`) gives the same result on `main` and on this branch: 519 passed, 5 skipped, 14 failed. All 14 failures are in `test_config.py` and `test_nltk_helper.py` and come from NLTK corpora that CI downloads and this machine does not have. ## Does this PR potentially affect the following parts? - [ ] Dependencies - [ ] Modify configurations - [ ] The public API - [ ] Other affects - [x] Nope -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
