Skip to content

Commit

Permalink
fix: 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 the ruby InfluxError message.
In case of an InfuxError, the reason (error message) 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

Refs: #133
  • Loading branch information
alxndrdude committed Jan 31, 2024
1 parent 9eb5d8b commit 41a7bf6
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 41a7bf6

Please sign in to comment.