3

In ArangoDB 2.5.2 (and maybe earlier), we had written code that relied on a value within a document allowing NULL characters.

In ArangoDB 2.6.1+, it appears that the NULL is acting as the string terminator, even when there may be more string data. How can we restore the previous behavior?

For example, if the value is "value\u0000SubValue1\u0000SubValue2", the newer version unfortunately truncates:

2.5.2 => "value\u0000SubValue1\u0000SubValue2"
2.6.2 => "value"

We are using the NULL to act as a delimiter as we know that is the one character that won't appear within the sub-strings.

Update

Here are the steps for reproducing the issue from the shell on Windows.

arangosh [demo]> db._create("SO")
[ArangoCollection 848312398088, "SO" (type document, status loaded)]
arangosh [demo]> db.SO.save({ "v":"a\u0001b"})
{
  "_id" : "SO/848317640968",
  "_rev" : "848317640968",
  "_key" : "848317640968"
}
arangosh [demo]> db.SO.document("SO/848317640968")
{
  "v" : "a\u0001b",
  "_id" : "SO/848317640968",
  "_rev" : "848317640968",
  "_key" : "848317640968"
}
arangosh [demo]> db.SO.save({ "v":"a\u0000b"})
{
  "_id" : "SO/848320262408",
  "_rev" : "848320262408",
  "_key" : "848320262408"
}
arangosh [demo]> db.SO.document("SO/848320262408")
{
  "v" : "a",      // the rest of the value has been truncated
  "_id" : "SO/848320262408",
  "_rev" : "848320262408",
  "_key" : "848320262408"
}

And, I've created an issue on GitHub.

6
  • I checked the linux version with the arangosh: db.test.any() { "_id" : "test/1714178880", "_key" : "1714178880", "_rev" : "1714178880", "a" : "a\u0000b\u0000c" }
    – fceller
    Jul 3, 2015 at 21:29
  • With OS and which driver/language do you use?
    – fceller
    Jul 3, 2015 at 21:30
  • Windows, .NET. Also tried using the Web API. Jul 4, 2015 at 1:26
  • Maybe it is better to open an issue on the .NET side on github?
    – fceller
    Jul 9, 2015 at 15:37
  • For me the current webinterface saves this as \\0 inside of the json; You may need to escape the \ here
    – dothebart
    Jul 9, 2015 at 15:53

1 Answer 1

1

This was indeed a bug, but it only occurs under specific circumstances.

Whether or not it is triggered depends on how the document was retrieved (JavaScript functions inside the server or via HTTP API, AQL or CRUD operations) and whether or not the document was internally saved in ShapedJson format or not.

I was able to reproduce the issue with 2.5 & 2.6 under Linux as well in the following cases when the document was retrieved via the HTTP REST API and using a single document read, i.e. via HTTP GET /_api/document//.

Here's how to reproduce:

  • create the collection and store the document containing the NUL attribute value:

    db._create("SO");
    db.SO.save({ "v": "a\u0000b", _key: "b" });
    
  • then query the document from inside the ArangoShell:

    db.SO.document("b")
    

This returns the truncated value:

{ 
  "v" : "a", 
  "_id" : "SO/b", 
  "_rev" : "4124146417077", 
  "_key" : "b" 
}

It works fine when the document was queried inside arangod, or when using one of the following methods from the ArangoShell:

  • db.<collection>.any()
  • db.<collection>.toArray()

I submitted a fix for this in the 2.6 branch, which will become release version 2.6.3 eventually.

Please note that using NUL bytes inside attribute values does not seem to have worked since at least April 2014 under the abovementioned circumstances, meaning it may not have worked in 2.5, and not even 2.4 and 2.3.

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.