Skip to content

Commit d5de6c9

Browse files
authored
fix: support influxdb v1.8 HTTP error response message (#134)
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
1 parent 9eb5d8b commit d5de6c9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 3.1.0 [unreleased]
22

3+
### Bug Fixes
4+
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.
5+
36
## 3.0.0 [2023-12-05]
47

58
### Bug Fixes

lib/influxdb2/client/influx_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(original = nil, message:, code:, reference:, retry_after:)
3232

3333
def self.from_response(response)
3434
json = JSON.parse(response.body)
35-
obj = new(message: json['message'] || '', code: response.code, reference: json['code'] || '',
35+
obj = new(message: json['message'] || json['error'] || '', code: response.code, reference: json['code'] || '',
3636
retry_after: response['Retry-After'] || '')
3737
obj
3838
rescue JSON::ParserError

0 commit comments

Comments
 (0)