Use of NULL in document Value truncated

In ArangoDB 2.5.2 (and possibly earlier), we wrote code that relied on a value within the document to allow for NULLs.

In ArangoDB 2.6.1+, it seems that NULL acts as a string terminator, even if there might be more string data. How can we restore the previous behavior?

For example, if the value is "value\u0000SubValue1\u0000SubValue2"

, a newer version unfortunately truncates:

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

      

We use NULL to act as a delimiter, since we know that this is the only character that will not appear in substrings.

Update

Following are the steps to reproduce the problem from a 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 created an issue on GitHub.

+3


source to share


1 answer


This was indeed a mistake, but it only happens under certain circumstances.

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

I was able to reproduce the issue with 2.5 and 2.6 under Linux, and also in the following cases where the document was restored via the HTTP REST API and using one document read, i.e. via HTTP GET / _api / document //.

Here's how to reproduce:

  • create a collection and save a document containing a NUL attribute value:

    db._create("SO");
    db.SO.save({ "v": "a\u0000b", _key: "b" });
    
          

  • then request the document inside ArangoShell:

    db.SO.document("b")
    
          

Returns a truncated value:



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

      

It works great when requesting a document inside arangod or when using one of the following methods from ArangoShell:

  • db.<collection>.any()

  • db.<collection>.toArray()

I have posted a fix for this to the 2.6 branch, which will eventually become the 2.6.3 version.

Note that using NUL bytes inside attribute values ​​didn't seem to work since at least April 2014 under the aforementioned circumstances, meaning it probably didn't work in version 2.5, not even 2.4 and 2.3.

+1


source







All Articles