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 53df47b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 3.1.0 [unreleased]

### Bug Fixes
1. [#134](https://github.com/influxdata/influxdb-client-ruby/pull/134): Support influxdb v1.8 HTTP error response message. Prior to this change, in case of an HTTP error response (influxDB v1.8) the InfluxError had empty message.

## 3.0.0 [2023-12-05]

### Bug Fixes
Expand Down
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 53df47b

Please sign in to comment.