fix: can't query vertex with number vertex id#329
Open
neoblackcap wants to merge 1 commit into
Open
Conversation
neoblackcap
commented
May 11, 2026
- make vertex api compactible with number type vertex id
- add test case for add/append/eliminate/remove vertex with number type vertex id
067b00d to
bc2719d
Compare
1. make vertex api compactible with number type vertex id 2. add test case for add/append/eliminate/remove vertex with number type vertex id
bc2719d to
e8b942b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the HugeGraph Python client’s vertex APIs to support querying/operating on vertices whose IDs are numeric (not only string IDs), and adds regression tests around these vertex operations.
Changes:
- Adjusted vertex REST routes to remove always-on quoting around
{vertex_id}, and added router-side formatting logic intended to quote only string vertex IDs. - Added schema/test coverage for a new
departmentvertex label used to exercise numeric vertex-id behavior. - Tweaked
getVerticesById()query construction to JSON-quote ids (strings quoted, numbers not).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| hugegraph-python-client/src/tests/client_utils.py | Adds new property keys and a department vertex label for numeric-id tests. |
| hugegraph-python-client/src/tests/api/test_graph.py | Adds new test cases covering append/eliminate/get/remove for numeric vertex IDs. |
| hugegraph-python-client/src/pyhugegraph/utils/huge_router.py | Adds special vertex_id formatting logic in the route formatter. |
| hugegraph-python-client/src/pyhugegraph/api/graph.py | Updates vertex endpoints to use unquoted {vertex_id} and adjusts getVerticesById() id quoting. |
| hugegraph-python-client/pyproject.toml | Minor dependency formatting adjustment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+152
to
+158
| elif "{vertex_id}" in path: | ||
| # fix vertex_id format process | ||
| # only quote string type vertex_id | ||
| vertex_id = all_kwargs.pop("vertex_id") | ||
| if isinstance(vertex_id, str): | ||
| vertex_id = "\"" + vertex_id + "\"" | ||
| all_kwargs['vertex_id'] = vertex_id |
|
|
||
| import functools | ||
| import inspect | ||
| import json |
| schema.vertexLabel("book").useCustomizeStringId().properties("name", "price").nullableKeys( | ||
| "price" | ||
| ).ifNotExist().create() | ||
| schema.vertexLabel("department").properties("name", "headcount", "floor").nullableKeys( |
| self.graph.getVertexById(vertex.id) | ||
| except NotFoundError as e: | ||
| msg = "\\'{}\\' does not exist".format(vertex.id) | ||
| logger.info(f'test_msg: {msg}') |
Comment on lines
+111
to
+118
| self.graph.removeVertexById(vertex.id) | ||
| try: | ||
| self.graph.getVertexById(vertex.id) | ||
| except NotFoundError as e: | ||
| msg = "\\'{}\\' does not exist".format(vertex.id) | ||
| logger.info(f'test_msg: {msg}') | ||
| self.assertTrue(msg in str(e)) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.