Closed drewr closed 7 years ago
I'll have to check, but I think this might break /_bulk
since it requires the trailing newline?
It's a good question. It seems like it should, but I've been using the patch with bulk and it works.
It looks like it causes the last operation to be missed with /_bulk
, for instance, if I do:
POST /_bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
The response is
{
"took" : 10,
"errors" : false,
"items" : [
{
"index" : {
"_index" : "test",
"_type" : "type1",
"_id" : "1",
"_version" : 13,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : false,
"status" : 200
}
},
{
"delete" : {
"found" : false,
"_index" : "test",
"_type" : "type1",
"_id" : "2",
"_version" : 13,
"result" : "not_found",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"status" : 404
}
}
]
}
Which shows it's missing the final operation (the update)
Thanks @drewr!
Oh, wow, that's a good catch. I didn't even consider that possibility because I thought ES errored on a dangling line. Updated to check if we really had an empty payload and only trim... nevermind I forgot to submit the comment and you already merged 😄
With no payload like below,
request-data
ends up with\n
. This causes ES to bomb trying to make sense ofnull
as the body.