Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Some exceptions could be raised before sending data to server #284

Merged
merged 1 commit into from
Jun 9, 2016

Conversation

adrianlzt
Copy link
Contributor

If this piece of code is executed:

from influxdb import InfluxDBClusterClient
client = InfluxDBClusterClient(
        [('10.0.0.18',8086)],"x","x","udo")

client.write_points([{"time": "1453118432", "measurement":"medida","fields": {"value": 3}}])

This exception is raised:

influxdb.exceptions.InfluxDBServerError: InfluxDB: no viable server!

The lib is telling us that there is some problem with the servers, but it is not actually the real problem.
The problem is using a string timestamp instead of integer.

The flow is:
https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py#L276 ->
https://github.com/influxdata/influxdb-python/blob/master/influxdb/line_protocol.py#L131 -> https://github.com/influxdata/influxdb-python/blob/master/influxdb/line_protocol.py#L17 ->
finally calling dateutil.parser.parse("1453120639") that raises:

ValueError: year is out of range

With this PR, that exception is catched and displayed to the user.

I think the error is assuming that all exceptions excluding InfluxDBClientError are server errors: https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py#L884

@aviau
Copy link
Collaborator

aviau commented Jun 9, 2016

Makes sense! Thank you for the PR!

@aviau aviau merged commit d9c5c1c into influxdata:master Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants