Skip to content

POST to /_bulk fails with The bulk request must be terminated by a newline #18

Description

@MMChrisHinshaw

Using the default install of aws-es-curl, and attempting to POST to /_bulk will result in the following error:
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "The bulk request must be terminated by a newline [\\n]" } ], "type": "illegal_argument_exception", "reason": "The bulk request must be terminated by a newline [\\n]" }, "status": 400 }

Modifying this line resolve(data.trim()); to remove the .trim() will get you past this error.

On my system, this file was located here after running npm install aws-es-curl -g
/opt/nvm/versions/node/v10.16.0/lib/node_modules/aws-es-curl/index.js

The command used was
cat stats.json | aws-es-curl -X POST "https://search-redacted.es.amazonaws.com/_bulk".

As bulk requests are multiple line, it would be nice to allow for the following:
aws-es-curl -X POST "https://search-redacted.es.amazonaws.com/_bulk" --data @stats.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions