Skip to content

Accept a String vertex id in IndexSerializer.removeElement (#4928) - #4937

Open
batrived wants to merge 1 commit into
JanusGraph:masterfrom
batrived:fix/4928-remove-element-string-id
Open

Accept a String vertex id in IndexSerializer.removeElement (#4928)#4937
batrived wants to merge 1 commit into
JanusGraph:masterfrom
batrived:fix/4928-remove-element-string-id

Conversation

@batrived

Copy link
Copy Markdown
Contributor

Fixes #4928.

IndexSerializer.removeElement rejected every vertex id which is not a Long, but the very next line calls element2String, which accepts a Long, a RelationIdentifier or a String. The two methods disagreed about what a valid element id is, and the stricter of them ran first.

A graph configured with graph.allow-custom-vid-types assigns String vertex ids. The only caller is StandardTransactionLogProcessor, which calls removeElement when the element of a restored transaction no longer exists. So recovering a transaction that deleted an indexed vertex threw IllegalArgumentException, the stale index document was never removed, and the recovery mechanism that exists to repair a diverged index could not complete.

This applies the fix suggested in the issue: accept the same vertex ids element2String accepts. A relation index still requires a RelationIdentifier.

Testing

IndexSerializerRemoveElementTest covers a String vertex id, a Long vertex id, a relation id, and the ids that must still be rejected. I confirmed the String case reproduces the reported failure without the fix:

IllegalArgument Invalid element id [customVertexId] provided for index: Mock for MixedIndexType

Each test also asserts the resulting document id round-trips back to the original element id through string2ElementId, so the document that gets removed is the right one, and that the entry list is empty, which is how a document removal is expressed.


For all changes:

  • Is there an issue associated with this PR? Is it referenced in the commit message?
  • Does your PR body contain #xyz where xyz is the issue number you are trying to resolve?
  • Has your PR been rebased against the latest commit within the target branch (typically master)?
  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you written and/or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0? — no new dependencies
  • If applicable, have you updated the LICENSE.txt file, including the main LICENSE.txt file in the root of this repository? — not applicable
  • If applicable, have you updated the NOTICE.txt file, including the main NOTICE.txt file found in the root of this repository? — not applicable

…h#4928)

removeElement rejected every vertex id which is not a Long, but the very next
line calls element2String, which encodes a Long, a RelationIdentifier or a
String. The two methods disagreed about a valid element id, and the stricter of
them ran first.

A graph configured with graph.allow-custom-vid-types assigns String vertex ids.
StandardTransactionLogProcessor calls removeElement when the element of a
restored transaction no longer exists, so recovering a transaction which deleted
an indexed vertex threw IllegalArgumentException. The stale index document was
never removed, and the recovery which exists to repair a diverged index could
not complete.

Accept the same vertex ids that element2String accepts. A relation index still
requires a RelationIdentifier.

Signed-off-by: Balmukund Trivedi <btrivedipublic@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@batrived
batrived force-pushed the fix/4928-remove-element-string-id branch from 6576b76 to cabd792 Compare August 13, 2026 17:10
@porunov
porunov requested a lite review from Copilot August 14, 2026 17:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Updates IndexSerializer.removeElement to accept String vertex IDs (in addition to Long) to support graphs configured with custom vertex ID types, and adds unit tests to validate accepted and rejected ID/category combinations.

Changes:

  • Allow String IDs when removing vertex documents from mixed indexes.
  • Add unit tests covering String vertex IDs, Long vertex IDs, relation IDs, and invalid ID/category combinations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
janusgraph-core/src/main/java/org/janusgraph/graphdb/database/IndexSerializer.java Expands vertex ID validation in removeElement to accept String IDs.
janusgraph-core/src/test/java/org/janusgraph/graphdb/database/IndexSerializerRemoveElementTest.java Adds regression/unit tests for removeElement ID handling and document-id roundtrip behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexSerializer.removeElement rejects String element ids, breaking mixed-index recovery for custom vertex id types

2 participants