Bucket Write node does not accept empty array

Hello @jaimebs

I identified that the Bucket Write node returns an error if the array is empty. Is this the expected behavior, or should the write node return successfully on writing?

Error = [ ]

Success = [ “” ]

Hi,

This could be associated with the data type in the bucket, if it has a string data type and you try to store a Boolean or integer, will give you that error, and vice versa, if you have a Boolean stored and try to save a string, as example.

You can try with an empty bucket and see if it accepts the empty array, btw I don’t know if it’s a good practice to store empty value, for database purposes.

Hope this helps.

hello @ega

I caught this error when trying to save a BIG JSON to Bucket. The data was imported from a JSON stored in FileStore.
I’m testing using a Bucket to store alarm logs (which are infrequent).
When trying to store a BIG JSON with a nested structure it was returning error. Only after investigating, I identified that it was the empty array.
I’m storing each element of the first JSON structure in a corresponding cell.
JSON example:
{
devide_id”: “test01”,
log_alarme”: { “a”: “info_00”,
“b”: { “b.1”: “info_01”,
“b.2”: “info_02”,
“b.3”: [ ],},
“c”: …

}
z_log”: {…}
}

If "b.3:" [ ] has an empty array, the error occurs,
But if the array has some information eg "b.3:" [" "], the node returns a success message.
How was the bucket:
due_id | log_alarm  | z_log
“test01” | {“a”: …“b”: …“c”… } | {…}

Hi @George_Santiago

This is actually not a bug from Node RED, but how the thinger server acts upon a payload with an empty array or object, which is not able to treat these fields. Following are examples or messages that is not able to treat.
{"msg":[]}, {"msg":{}} or {"msg1":"field1", "msg2": {}}

As a workaround you could clean the message before the bucket-write node with a function node and remove any empty array and its field.

When adding quotation marks you are actually giving it a value of empty string to the array, which is then able to store in the backend database as long as there is no previous value with a different type in that field.

1 Like