How to drop a Gremlin vertex that contains "/" in the id field.

Jason Koncsol 20 Reputation points Microsoft Employee
2025-10-16T17:32:44.3533333+00:00

I cannot drop vertices that contain the "/" character in the id field. I get an error message "StatusCode":404,"SubStatusCode":0,"RequestCharge":0,"RequestUri":"dbs/AMER/colls/AMER%20US%20West/docs/SJC20-FPDEVICE-F01SER01-C1M-31/33","ErrorMessage":"The value 'dbs/AMER/colls/AMER%20US%20West/docs/SJC20-FPDEVICE-F01SER01-C1M-31/33' specified for query '$resolveFor' is invalid.\r\nActivityId: 8afb4066-7d58-4ad8-bbf5-4e483903e1f1,"
I've tried dropping via .NET client as well as in the console but get the same error either way. I've modified the code I use to create the vertices via bulk uploader to replace "/" with "_" going forward but need to be able to remove the existing vertices with "/" already in the id.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Pratyush Vashistha 4,815 Reputation points Microsoft External Staff Moderator
    2025-10-21T04:04:36.08+00:00

    Hello Jason Koncsol,

    This problem often relates to how special characters in IDs (like "/") are handled in Azure Cosmos DB Gremlin API. Could you please share the exact Gremlin query or .NET code snippet you are using to drop the vertex? Also, are you specifying the partition key when trying to remove these vertices, and if so, what is the value being provided? This will help clarify if the error is due to improper ID encoding, partition key mismatch, or API limitation.

    If you have additional details about your graph’s schema—such as whether your graph is using custom partition keys or default settings—please provide that as well. This will help pinpoint the best way to remove those problematic vertices.

    Meanwhile while you answer above questions, you can try the following solutions

    1. When referencing vertices with special characters in Gremlin queries, try URL encoding the vertex ID. Replace "/" with "%2F" in your drop operations. For example, if your vertex ID is "SJC20-FPDEVICE-F01SER01-C1M-31/33", use "SJC20-FPDEVICE-F01SER01-C1M-31%2F33" in your Gremlin query.
    2. Ensure you're specifying the correct partition key when attempting to drop vertices. If your graph uses partition keys, the drop operation must include the proper partition key parameter, especially when using the .NET client.
    3. Try using the .hasId() step in your Gremlin traversal instead of direct ID referencing. This approach can sometimes handle special characters more effectively.

    Thanks

    Pratyush


Answer recommended by moderator
  1. Amira Bedhiafi 41,036 Reputation points Volunteer Moderator
    2025-10-16T17:58:21.56+00:00

    Hello Jason !

    Thank you for posting on Microsoft Learn Q&A.

    Don’t try to point-read by id because in Cosmos DB using the Gremlin API a slash inside the id makes the service try to resolve a document path (docs/<id>), which breaks so instead, select the vertex by partition key with a filter on id() and then drop it.

    g.V().
      has('pk', 'AMER US West').          // your partition key value
      where(id().is('SJC20-FPDEVICE-F01SER01-C1M-31/33')).
      drop()
    

    if you want to use parameter bindings in .NET :

    var bindings = new Dictionary<string, object> {
      ["pk"] = "AMER US West",
      ["vid"] = "SJC20-FPDEVICE-F01SER01-C1M-31/33"
    };
    await client.SubmitAsync(
      "g.V().has('pk', pk).where(id().is(vid)).drop()", bindings);
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.