Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Allow use of Faraday v2 #37

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

agis
Copy link
Member

@agis agis commented Oct 27, 2023

Obsoletes #34

@agis agis requested a review from gkats October 27, 2023 11:05
@agis agis requested a review from a team as a code owner October 27, 2023 11:05
@agis agis requested a review from kostaspt October 27, 2023 11:05
Copy link
Member

@kostaspt kostaspt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @agis!

clerk-sdk-ruby.gemspec Outdated Show resolved Hide resolved
@agis agis force-pushed the CORE-68-faraday2-compatibility branch from b538acb to 0d8edaf Compare October 27, 2023 11:08
@agis agis merged commit 437ce80 into main Oct 27, 2023
@agis agis deleted the CORE-68-faraday2-compatibility branch October 27, 2023 11:28
@agis agis mentioned this pull request Oct 27, 2023
@dugjason
Copy link

I'm pretty sure this change broke the Rack middleware.
You can reproduce by running the rails starter app https://github.com/clerkinc/clerk-rails-starter with v2.11 (it works fine on v2.10)
Rails throws Clerk::Errors::Fatal

{"errors"=>[{"message"=>"Invalid Authorization header format", "long_message"=>"Invalid Authorization header format. Must be \"Bearer <YOUR_API_KEY>\"", "code"=>"authorization_header_format_invalid"}], "clerk_trace_id"=>"f9c19fa25408fddb05749cff547bc42f", "status"=>401}

With the stack trace pointing to https://github.com/clerkinc/clerk-sdk-ruby/blob/main/lib/clerk/sdk.rb#L115
I think it's the case that when using Faraday v2.x, the api_key is no longer being set

clerk-sdk-ruby (2.11.0) lib/clerk/sdk.rb:115:in `request'
clerk-sdk-ruby (2.11.0) lib/clerk/sdk.rb:164:in `interstitial'
clerk-sdk-ruby (2.11.0) lib/clerk/rack_middleware_v2.rb:202:in `unknown'
clerk-sdk-ruby (2.11.0) lib/clerk/rack_middleware_v2.rb:158:in `call'
rack (3.0.8) lib/rack/tempfile_reaper.rb:20:in `call'
rack (3.0.8) lib/rack/etag.rb:29:in `call'
rack (3.0.8) lib/rack/conditional_get.rb:31:in `call'
rack (3.0.8) lib/rack/head.rb:15:in `call'
actionpack (7.1.1) lib/action_dispatch/http/permissions_policy.rb:36:in `call'
actionpack (7.1.1) lib/action_dispatch/http/content_security_policy.rb:33:in `call'
rack-session (2.0.0) lib/rack/session/abstract/id.rb:272:in `context'
rack-session (2.0.0) lib/rack/session/abstract/id.rb:266:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/cookies.rb:689:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (7.1.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (7.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/actionable_exceptions.rb:16:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
web-console (4.2.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.1) lib/web_console/middleware.rb:19:in `block in call'
web-console (4.2.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.1) lib/web_console/middleware.rb:17:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (7.1.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (7.1.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (7.1.1) lib/active_support/tagged_logging.rb:135:in `block in tagged'
activesupport (7.1.1) lib/active_support/tagged_logging.rb:39:in `tagged'
activesupport (7.1.1) lib/active_support/tagged_logging.rb:135:in `tagged'
activesupport (7.1.1) lib/active_support/broadcast_logger.rb:232:in `method_missing'
railties (7.1.1) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/remote_ip.rb:92:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/request_id.rb:28:in `call'
rack (3.0.8) lib/rack/method_override.rb:28:in `call'
rack (3.0.8) lib/rack/runtime.rb:24:in `call'
activesupport (7.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/server_timing.rb:59:in `block in call'
actionpack (7.1.1) lib/action_dispatch/middleware/server_timing.rb:24:in `collect_events'
actionpack (7.1.1) lib/action_dispatch/middleware/server_timing.rb:58:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/static.rb:25:in `call'
rack (3.0.8) lib/rack/sendfile.rb:114:in `call'
actionpack (7.1.1) lib/action_dispatch/middleware/host_authorization.rb:141:in `call'
railties (7.1.1) lib/rails/engine.rb:529:in `call'
puma (6.4.0) lib/puma/configuration.rb:272:in `call'
puma (6.4.0) lib/puma/request.rb:100:in `block in handle_request'
puma (6.4.0) lib/puma/thread_pool.rb:378:in `with_force_shutdown'
puma (6.4.0) lib/puma/request.rb:99:in `handle_request'
puma (6.4.0) lib/puma/server.rb:443:in `process_client'
puma (6.4.0) lib/puma/server.rb:241:in `block in run'
puma (6.4.0) lib/puma/thread_pool.rb:155:in `block in spawn_thread'

agis added a commit that referenced this pull request Oct 31, 2023
This fixes a regression introduced with #37, which caused the Clerk API
key to not be properly set when requesting Clerk's Backend API, when
Faraday v2 was used.

Fixes #37 (comment)
@agis
Copy link
Member Author

agis commented Oct 31, 2023

Thanks for reporting this and apologies for the inconvenience @dugjason! Indeed this patch was buggy, in that when using Faraday v2 it didn't actually set the API key properly, hence the API error. I've released 2.11.1 which fixes this (includes #38).

agis added a commit that referenced this pull request Oct 31, 2023
This fixes a regression introduced with #37, which caused the Clerk API
key to not be properly set when requesting Clerk's Backend API, when
Faraday v2 was used.

Fixes #37 (comment)
@adenta
Copy link

adenta commented Nov 4, 2023

2.11.1 isn't showing up:

➜  bramoor_rails git:(main) ✗ bundle install
Fetching gem metadata from https://rubygems.org/.........
Could not find gem 'clerk-sdk-ruby (~> 2.11.1)' in rubygems repository https://rubygems.org/ or installed locally.

The source contains the following gems matching 'clerk-sdk-ruby':
  * clerk-sdk-ruby-1.0.0
  * clerk-sdk-ruby-1.0.1
  * clerk-sdk-ruby-1.0.2
  * clerk-sdk-ruby-1.0.3
  * clerk-sdk-ruby-2.0.0.alpha.1
  * clerk-sdk-ruby-2.0.0
  * clerk-sdk-ruby-2.0.1
  * clerk-sdk-ruby-2.0.2
  * clerk-sdk-ruby-2.0.3
  * clerk-sdk-ruby-2.0.4
  * clerk-sdk-ruby-2.1.1
  * clerk-sdk-ruby-2.1.2
  * clerk-sdk-ruby-2.2.0
  * clerk-sdk-ruby-2.3.0
  * clerk-sdk-ruby-2.4.0
  * clerk-sdk-ruby-2.5.0
  * clerk-sdk-ruby-2.6.0
  * clerk-sdk-ruby-2.7.0
  * clerk-sdk-ruby-2.8.0
  * clerk-sdk-ruby-2.9.0.beta1
  * clerk-sdk-ruby-2.9.0.beta2
  * clerk-sdk-ruby-2.9.0.beta3
  * clerk-sdk-ruby-2.9.0
  * clerk-sdk-ruby-2.10.0.beta1
  * clerk-sdk-ruby-2.10.0.beta2
  * clerk-sdk-ruby-2.10.0
  * clerk-sdk-ruby-2.11.0

@dimkl
Copy link
Contributor

dimkl commented Nov 6, 2023

@adenta we have released the clerk-sdk-ruby (~> 2.11.1) in rubygems.orgs. Sorry for the inconvenience and thank you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants