Skip to content
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

Regex for error extraction fails with type conflict errors #14

Closed
patHyatt opened this issue Aug 10, 2016 · 1 comment
Closed

Regex for error extraction fails with type conflict errors #14

patHyatt opened this issue Aug 10, 2016 · 1 comment

Comments

@patHyatt
Copy link
Contributor

Hey there,

Given the following error response:

{"error":"write failed: field type conflict: input field \"value\" on measurement \"Bucket-Analytics-Single-Duration\" is type float64, already exists as type integer"}

In InfluxDBClient.cs
The errorLinePattern regex fails to extract any parts, yielding an ArgumentOutOfRangeException when building out the InfluxDBException on line ~217

  throw new InfluxDBException(partialWrite ? "Partial Write" : "Failed to Write", String.Format("{0}: {1} due to {2}", partialWrite ? "Partial Write" : "Failed to Write", parts?[0], parts?[2]), l);

The original error occurs in InfluxDB when a metric is initially written as one type, and subsequent types are different.

This was confirmed using the following test on the current master branch.

try
{
    var client = new InfluxDBClient("http://my.influx.server:8086", "Development", "mypassword");

    var points = new List<IInfluxDatapoint>();

    var firstPoint = new InfluxDatapoint<int>();
    firstPoint.UtcTimestamp = DateTime.UtcNow;
    firstPoint.Tags.Add("Environment", "Development");
    firstPoint.Fields.Add("value", 123);
    firstPoint.MeasurementName = "Bucket-Analytics-Single-Duration";
    firstPoint.Precision = TimePrecision.Milliseconds;
    points.Add(firstPoint);


    var secondPoint = new InfluxDatapoint<double>();
    secondPoint.UtcTimestamp = DateTime.UtcNow;
    secondPoint.Tags.Add("Environment", "Development");
    secondPoint.Fields.Add("value", 123.1234);
    secondPoint.MeasurementName = "Bucket-Analytics-Single-Duration";
    secondPoint.Precision = TimePrecision.Milliseconds;
    points.Add(secondPoint);


    var r = await client.PostPointsAsync("Development", points);
    Assert.IsTrue(r, "PostPointsAsync retunred false");
}
catch (Exception e)
{

    Assert.Fail("Unexpected exception of type {0} caught: {1}",
                e.GetType(), e.Message);
    return;
}
@mvadu
Copy link
Contributor

mvadu commented Aug 10, 2016

Nice catch Patrick, never tested this combination. Currently I am away on work, I will push a fix once I get chance. In between if you want to push a PR, you are welcome. Please do add your test to the unit test project as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants