InfluxDB.Net icon indicating copy to clipboard operation
InfluxDB.Net copied to clipboard

Can't Write Point with Empty String Tag

Open Genmutant opened this issue 7 years ago • 1 comments

Hi! I can't write a point containing a Tag with an empty string. I wrote the following unit test based on the existing ones:

        private Dictionary<string, object> EmptyStringTag()
        {
            return new Dictionary<string, object>
            {
                {"tag_string", string.Empty}
            };
        }
        [Test]
        public async Task DbWrite_OnPointWithEmptyStringTag_ShouldWritePoint()
        {
            var rnd = new Random();
            var fixture = new Fixture();
            fixture.Customize<Point>(c => c
                .With(p => p.Measurement, CreateRandomMeasurementName())
                .Do(p => p.Tags = EmptyStringTag())
                .Do(p => p.Fields = NewFields(rnd))
                .OmitAutoProperties());
            var points = fixture.CreateMany<Point>(1).ToArray();
            var timestamp = DateTime.UtcNow.AddDays(-5);
            foreach (var point in points)
            {
                timestamp = timestamp.AddMinutes(1);
                point.Timestamp = timestamp;
            }
            var writeResponse = await _influx.WriteAsync(_dbName, points);
            writeResponse.Success.Should().BeTrue();
        }

which failes with the Error:

InfluxDB.Net.Infrastructure.Influx.InfluxDbApiException : InfluxDb API responded with status code=BadRequest, response={"error":"unable to parse 'FakeMeasurement1517307523440,tag_string= field_bool=true,field_int=1446281079i,field_decimal=0.922650927176071,field_float=0.04777522,field_datetime=1517311123442 1516875583442': missing tag value"}

Genmutant avatar Jan 30 '18 10:01 Genmutant

It seems that is expected behaviour with influxDb. Maybe the library could filter tags with empty string values and not send them?

Genmutant avatar Jan 30 '18 10:01 Genmutant