-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bruno won't send ndjson body properly #1648
Comments
When you use But using "text" as body-type absolutely should work. I encountered the same bug in my workaround here: #1768 (comment) |
Aha! It seems this behavior only happens if you manually set the |
It's not standard JSON but It works with curl or any other client as Elasticsearch accepts this Content-Type. Bruno is messing with the content. At least if it's not a proper JSON I don't think it's good to turn it into a big JSON string, that's not what user ever intends. I think modifying body should never happen, unless you want to add some goodies, e.g. I saw if I comment a JSON line with
It doesn't work I tried it 😅, body type doesn't change the behavior. Text or JSON body, with or without JSON content type, it will mess up the body.
Even if I don't set any headers this will happen as well. The only solution is what you said, setting content type to |
Unfortunately, this behavior is (mostly) caused by the underlying axios library: https://github.com/axios/axios/blob/d844227411263fab39d447442879112f8b0c8de5/lib/defaults/index.js#L42 I tend to agree with @Rmaan : Bruno is a testing tool and should send the body exactly as I define it, even if that violates some standard. Seeing what an API does with malformed data is a core part of testing. It is possible to remove the default transforms from axios, and we should probably do that, but this could potentially break usage in other places. |
Interesting, I think we can copy the default transformer and remove the |
Context
In Elasticsearch, when you want to do a bulk indexing, you send all documents in JSON separated by new lines (known as ndjson or jsonl format). According to standard and Elasticsearch, body should end with a new line.
Problem
In Bruno, it seems there's no way to send a body that ends with a new line, I tried JSON format or text, it doesn't matter. Seems somehow newline is removed somewhere. When I use "generate code" and copy the curl it's fine but when I run it in bruno Elasticsearch complains.
Sample .bru file:
Sample cURL:
Error returned from Elasticsearch (only when run with bru):
When I run an nc on my local, I get a weird body being sent:
BTW keep up good work 🙌 I'm waiting for my golden edition☺️
The text was updated successfully, but these errors were encountered: