Skip to content

Commit

Permalink
Fix #133 - support influxdb v1.8 HTTP error response message
Browse files Browse the repository at this point in the history
An influxdb v1.8 HTTP error response message was not correctly transfered to ruby InfluxError message.
In case of an InfuxError, the reason (except status code) was not traceable.

How the fix works:
- InfluxDB v1.8 and v2.x provide Error details in the json-rsp body
- InfluxDB v2.x uses the `message` key for this
- InfluxDB v1.8 uses the `error` key for this

-> previously only `message` was supported
-> now, in case `message` is empty, `error` is checked
  • Loading branch information
alxndrdude committed Jan 25, 2024
1 parent 9eb5d8b commit bca01b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/influxdb2/client/influx_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(original = nil, message:, code:, reference:, retry_after:)

def self.from_response(response)
json = JSON.parse(response.body)
obj = new(message: json['message'] || '', code: response.code, reference: json['code'] || '',
obj = new(message: json['message'] || json['error'] || '', code: response.code, reference: json['code'] || '',
retry_after: response['Retry-After'] || '')
obj
rescue JSON::ParserError
Expand Down

0 comments on commit bca01b1

Please sign in to comment.