Skip to content

Commit

Permalink
fix(elasticsearch): Ignore pipeline argument if it is an empty stri…
Browse files Browse the repository at this point in the history
…ng (vectordotdev#18248)

Fixes: vectordotdev#18246

Signed-off-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jszwedko authored Aug 15, 2023
1 parent 50685f9 commit d9dbed8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sinks/elasticsearch/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ impl ElasticsearchCommon {
);

if let Some(pipeline) = &config.pipeline {
query_params.insert("pipeline".into(), pipeline.into());
if !pipeline.is_empty() {
query_params.insert("pipeline".into(), pipeline.into());
}
}

let bulk_url = {
Expand Down
22 changes: 22 additions & 0 deletions src/sinks/elasticsearch/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ async fn ensure_pipeline_in_params() {
assert_eq!(common.query_params["pipeline"], pipeline);
}

#[tokio::test]
async fn ensure_empty_pipeline_not_in_params() {
let index = gen_index();
let pipeline = String::from("");

let config = ElasticsearchConfig {
endpoints: vec![http_server()],
bulk: BulkConfig {
index,
..Default::default()
},
pipeline: Some(pipeline.clone()),
batch: batch_settings(),
..Default::default()
};
let common = ElasticsearchCommon::parse_single(&config)
.await
.expect("Config error");

assert_eq!(common.query_params.get("pipeline"), None);
}

#[tokio::test]
async fn structures_events_correctly() {
let index = gen_index();
Expand Down

0 comments on commit d9dbed8

Please sign in to comment.