multiwoven-integrations 0.43.6 → 0.43.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d254a8a952d1a94a315e5456a9f0e2d5e8b9599c32e7dada1adbb7e4f7f165cd
4
- data.tar.gz: 18c66ab6d1c33d5bb0c6ff06da6e4fd0586a902ce2c96644c6b13578234d8e8c
3
+ metadata.gz: b171a1cc51b28558fb343520c6a867e9a2b2aa25c087ba400421b5a2b3da7590
4
+ data.tar.gz: 3ce2cd2a913e5b938d8c6580272db97669019b0b23f91d75d9b2722dfc6d9746
5
5
  SHA512:
6
- metadata.gz: 221d297aa3e23f54b11c262c63c645119a6faddd157cd3524857ec4b2e13a199501fcbbebcdce1bd573826fcee14fc4d115857e1d3df3de1d6d73bafe1e13e4b
7
- data.tar.gz: 5bb37b559c91fb0402c83048f676a9c1c918b8be6401a99176db3f07147bb11660dba473f572a86229cf1328ad84091c2e8b56cc0f3401819e6ed79d11c18780
6
+ metadata.gz: d3dd73536846bd3620ded680aaf86c33019b693420974bbe65511ae4ee3f91b9ba91a3d75fe9d660db7ae4092fccaef7b60ed690de789b8e394850be69aa67dc
7
+ data.tar.gz: 2a187270474321f4d52e657f3bb9d871e418bae877a8fa4d6c6337abb657bb0f818c1d2d7197cb9c0e6e253211533903a34518c27c545f29b18a654fdffa28f9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### [0.43.7]
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * OAuth token requests rejected with a 4xx other than 408 or 429 raise `OauthTokenRequestError` instead of a bare `RuntimeError` (BE-2068)
9
+
3
10
  ### [0.43.3]
4
11
 
5
12
 
@@ -21,6 +21,8 @@ module Multiwoven
21
21
  # should benefit from the cache. Without it, a fresh token is fetched every
22
22
  # call — safe but wasteful.
23
23
  module OauthClientCredentials
24
+ class OauthTokenRequestError < RuntimeError; end
25
+
24
26
  AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS = "oauth_client_credentials"
25
27
  AUTH_TYPE_PRIVATE_KEY_JWT = "oauth_private_key_jwt"
26
28
  OAUTH_AUTH_TYPES = [AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS, AUTH_TYPE_PRIVATE_KEY_JWT].freeze
@@ -33,6 +35,7 @@ module Multiwoven
33
35
  # Refresh access tokens this many seconds before their advertised expiry,
34
36
  # so a token that expires mid-request doesn't leave the connector.
35
37
  TOKEN_EXPIRY_BUFFER_SECONDS = 300
38
+ TRANSIENT_HTTP_STATUSES = %w[408 429].freeze
36
39
 
37
40
  def build_headers(connection_config)
38
41
  headers = (connection_config[:headers] || {}).to_h.dup
@@ -76,7 +79,7 @@ module Multiwoven
76
79
  else
77
80
  post_client_secret_token_request(connection_config)
78
81
  end
79
- raise "OAuth token request failed: #{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
82
+ raise_token_request_error(response) unless response.is_a?(Net::HTTPSuccess)
80
83
 
81
84
  body = JSON.parse(response.body)
82
85
  access_token = body["access_token"]
@@ -87,6 +90,17 @@ module Multiwoven
87
90
  access_token
88
91
  end
89
92
 
93
+ def raise_token_request_error(response)
94
+ message = "OAuth token request failed: #{response.code} #{response.body}"
95
+ raise OauthTokenRequestError, message if rejected_token_request?(response)
96
+
97
+ raise message
98
+ end
99
+
100
+ def rejected_token_request?(response)
101
+ response.is_a?(Net::HTTPClientError) && !TRANSIENT_HTTP_STATUSES.include?(response.code)
102
+ end
103
+
90
104
  def post_client_secret_token_request(connection_config)
91
105
  token_url = connection_config[:token_url]
92
106
  client_id = connection_config[:client_id]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.43.6"
5
+ VERSION = "0.43.7"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.6
4
+ version: 0.43.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P