Skip to content

Empty bulk request gives weird ElasticSearch error #279

Closed
@q42jaap

Description

@q42jaap

I didn't realize that my bulk request was empty. NEST sent a completely empty request:

Request:

POST http://127.0.0.1:9200/_bulk HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: 127.0.0.1:9200
Content-Length: 0

Response:

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Content-Length: 86

{"error":"Failed to derive xcontent from org.elasticsearch.common.bytes.BytesArray@0"}

Code:

client.Bulk(bulk => {
    foreach (var x in xxx)
    {
      bulk.Index<X>(index => index
        .Object(x));
    }
    return bulk;
});

It might be a good idea for NEST to intercept this case and generate a better error... It also might be a breaking (since NEST doesn't throw exceptions right now)...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions