From 33129d5e5b2a9e1a70f90ea2b366ff5c3d6345a2 Mon Sep 17 00:00:00 2001 From: Igor Gaponenko Date: Wed, 14 Sep 2022 23:19:01 +0000 Subject: [PATCH] Fixed a bug in the worker ingest service --- src/replica/IngestHttpSvcMod.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/replica/IngestHttpSvcMod.cc b/src/replica/IngestHttpSvcMod.cc index 4d19bd9b20..e4321d5ec9 100644 --- a/src/replica/IngestHttpSvcMod.cc +++ b/src/replica/IngestHttpSvcMod.cc @@ -133,18 +133,20 @@ IngestRequest::Ptr IngestHttpSvcMod::_createRequest(bool async) const { string const url = body().required("url"); csv::DialectInput dialectInput; - // Allow "column_separator" for the sake of the backward compatibility with the older - // version of the API. The parameter "column_separator" if present will override the one - // of "fields_terminated_by" - dialectInput.fieldsTerminatedBy = body().optional( - "column_separator", - body().optional("fields_terminated_by", csv::Dialect::defaultFieldsTerminatedBy)); + // Allow an empty string in the input. Simply replace the one (if present) with + // the corresponding default value of the parameter. + auto const getDialectParam = [&](string const& param, string const& defaultValue) -> string { + string val = body().optional(param, defaultValue); + if (val.empty()) val = defaultValue; + return val; + }; + dialectInput.fieldsTerminatedBy = + getDialectParam("fields_terminated_by", csv::Dialect::defaultFieldsTerminatedBy); dialectInput.fieldsEnclosedBy = - body().optional("fields_enclosed_by", csv::Dialect::defaultFieldsEnclosedBy); - dialectInput.fieldsEscapedBy = - body().optional("fields_escaped_by", csv::Dialect::defaultFieldsEscapedBy); + getDialectParam("fields_enclosed_by", csv::Dialect::defaultFieldsEnclosedBy); + dialectInput.fieldsEscapedBy = getDialectParam("fields_escaped_by", csv::Dialect::defaultFieldsEscapedBy); dialectInput.linesTerminatedBy = - body().optional("lines_terminated_by", csv::Dialect::defaultLinesTerminatedBy); + getDialectParam("lines_terminated_by", csv::Dialect::defaultLinesTerminatedBy); string const httpMethod = body().optional("http_method", "GET"); string const httpData = body().optional("http_data", string());