standard_id 0.64.0 → 0.64.1

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: 299bfc41d084764b04761feb2ad82437e7ac0cd3ea4dd47667c4e021519211ad
4
- data.tar.gz: 17c66fdb33e21a1f9b2d694d9e310193133557617b000962089a39db1eb4288e
3
+ metadata.gz: bc6e2b7114dad7aa0475bd6fcd96f6a4c29c34eb91a2667cfaab83ee4f17089d
4
+ data.tar.gz: 7bf5da56fcc0572da349de796a74442585f529a3522bdcdaf9c1421e63cc6fc4
5
5
  SHA512:
6
- metadata.gz: '08cd8132db371312d928220af8f3a520bd9cc5610c02e255a17e298d5516001a82caabf9c22b16d48898d2f47834742cce8e87f0c4c75389448b3aa82a6aedfc'
7
- data.tar.gz: '0867392da53c2a1750bec89e41339e2166a63477c8ed88b1553f33a90ecad045b1026ff9c4fda74184017585ce5388533b6aa0d37858ced36586e994bb2eb469'
6
+ metadata.gz: df80d0509429e338f1c6be7057ddf5606ef5b70555a90e1e6b8344cf05b341d2836a729590f2bd596fd2faf81b97d5e0d22eb1cab9ec5a60f2b02373f0c8fc40
7
+ data.tar.gz: dc8312147249dd52500a68f113523fae4926171a7458fb27ff24b33ef21686dd646668b0cdea0cc8181d2d1dc04c20810b8bb483dee93cd8744959d4a1886104
data/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.64.1] - 2026-11-25
11
+
12
+ ### Fixed
13
+
14
+ - **Errors the `network_wrapper` passes through now survive a provider's error mapping.** An error
15
+ the wrapper lets out unchanged (one raised after the block returned, a programming error, or one
16
+ listed in `config.network_wrapper_passthrough_errors`) was still turned into an `OAuthError` by
17
+ `StandardId::Providers::Base#rescue_to_oauth_error`, which wraps every plugin sign-in call (code
18
+ exchange, JWKS, tokeninfo, userinfo). The sign-in failed as a handled 400 `invalid_request` such as
19
+ "Failed to fetch Google JWKS: no circuit registered for :oauth_google", which named the circuit and
20
+ never reached the error tracker. `StandardId::NetworkWrapper` now marks such errors
21
+ (`StandardId::NetworkWrapper.passed_through?`) and `rescue_to_oauth_error` re-raises them
22
+ unchanged. The request's own errors (timeouts, refused connections) and refusals that become
23
+ `ProviderUnavailableError` map as before.
24
+
10
25
  ## [0.64.0] - 2026-11-25
11
26
 
12
27
  ### Added
data/README.md CHANGED
@@ -815,6 +815,13 @@ handled, so it may name a class from a gem that isn't loaded; a name that
815
815
  resolves to nothing is ignored. An error passes through when it `is_a?` any
816
816
  entry. Errors the request itself raised are passed through regardless.
817
817
 
818
+ A passed-through error also gets past the provider plugins' own error mapping
819
+ (`rescue_to_oauth_error`, which turns other failures into an `OAuthError`), so
820
+ it propagates out of the sign-in instead of becoming a 400 that names your
821
+ circuit (fixed in 0.64.1). `StandardId::NetworkWrapper.passed_through?(error)`
822
+ tells you whether an error left the wrapper this way, for a plugin with its own
823
+ rescue around a provider request.
824
+
818
825
  `provider` is the plugin's name
819
826
  (`:google`, `:apple`, ...), or `:standard_id` for a plugin release that does not
820
827
  pass one yet. A lambda must take the block as `&block`; the boot check rejects
@@ -35,12 +35,21 @@ module StandardId
35
35
  # ProviderUnavailableError carries it as `retry_after`, which the API
36
36
  # sends as a Retry-After header.
37
37
  #
38
+ # An error let out under rules 3, 4 or 5 is marked as passed through (see
39
+ # .passed_through?), so StandardId::Providers::Base#rescue_to_oauth_error,
40
+ # which wraps every provider sign-in call, re-raises it unchanged instead of
41
+ # turning it into an OAuthError. The block's own errors (rule 2) are not
42
+ # marked: they map exactly as they do with no wrapper.
43
+ #
38
44
  # Non-StandardError exceptions (Interrupt, ...) are never touched.
39
45
  module NetworkWrapper
40
46
  # Errors a host wrapper raises because its own code is wrong, never
41
47
  # because the provider is down. NameError covers NoMethodError.
42
48
  PROGRAMMING_ERRORS = [NameError, TypeError, ArgumentError].freeze
43
49
 
50
+ # Extended into an error the wrapper let out under rules 3 to 5.
51
+ module PassedThrough; end
52
+
44
53
  module_function
45
54
 
46
55
  # @param provider [Symbol, String, nil] the remote service (`:google`,
@@ -74,14 +83,25 @@ module StandardId
74
83
  raise
75
84
  rescue StandardError => e
76
85
  raise if raised.any? { |error| error.equal?(e) }
77
- raise if returned
78
- raise if PROGRAMMING_ERRORS.any? { |klass| e.is_a?(klass) }
79
- raise if passthrough_errors.any? { |klass| e.is_a?(klass) }
86
+ if returned || PROGRAMMING_ERRORS.any? { |klass| e.is_a?(klass) } || passthrough_errors.any? { |klass| e.is_a?(klass) }
87
+ # Never frozen: Ruby raises a copy of a frozen exception.
88
+ e.extend(PassedThrough) unless e.frozen?
89
+ raise
90
+ end
80
91
 
81
92
  raise StandardId::ProviderUnavailableError.new(provider: provider, retry_after: retry_after_from(e)), cause: e
82
93
  end
83
94
  end
84
95
 
96
+ # Whether the wrapper let this error out on purpose (rules 3 to 5), so a
97
+ # caller that turns errors into OAuthErrors must re-raise it unchanged.
98
+ #
99
+ # @param error [Exception]
100
+ # @return [Boolean]
101
+ def passed_through?(error)
102
+ error.is_a?(PassedThrough)
103
+ end
104
+
85
105
  # The classes in `config.network_wrapper_passthrough_errors`. A String
86
106
  # names a class that may not be loaded (it may come from a gem the host
87
107
  # has not required), so it is resolved on each call and skipped while it
@@ -453,6 +453,12 @@ module StandardId
453
453
  # errors — is wrapped so callers only ever handle OAuthError, with the
454
454
  # original exception kept as `cause`.
455
455
  #
456
+ # An error the host's network_wrapper let out on purpose (see
457
+ # StandardId::NetworkWrapper.passed_through?: a programming error, a
458
+ # listed misconfiguration such as an unregistered circuit, or an error
459
+ # after the request went through) propagates unchanged too, so it
460
+ # reaches the error tracker instead of becoming a handled 400.
461
+ #
456
462
  # @param message_prefix [String, nil] Prepended to the wrapped error's
457
463
  # message, e.g. "Failed to fetch JWK" → "Failed to fetch JWK: <msg>"
458
464
  # @return [Object] the block's return value
@@ -471,6 +477,8 @@ module StandardId
471
477
  rescue StandardId::OAuthError
472
478
  raise
473
479
  rescue StandardError => e
480
+ raise if StandardId::NetworkWrapper.passed_through?(e)
481
+
474
482
  message = message_prefix ? "#{message_prefix}: #{e.message}" : e.message
475
483
  raise StandardId::OAuthError, message, cause: e
476
484
  end
@@ -1,3 +1,3 @@
1
1
  module StandardId
2
- VERSION = "0.64.0"
2
+ VERSION = "0.64.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.0
4
+ version: 0.64.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rarebit One