-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix deprecation warning since Faraday 1.7.1 #1359
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like set_authorization_header
was also removed upstream in lostisland/faraday#1308
Based on the deprecation message and diff in that PR, and adjusting for consistency, I think we want:
-http.basic_auth "username", "password"
+http.request :authorization, "Basic", "username", "password"
-http.authorization "token", "access-token"
+http.request :authorization, "token", "access-token"
-http.authorization "Bearer", "bearer-token"
+http.request :authorization, "Bearer", "bearer-token"
Actually, it looks like http.request :authorization, "Basic", "username", "password" isn't backwards compatible with Faraday versions prior to that PR. It blows up because of the extra password argument. One forward and backward compatible way of handling it would be to encode the header ourselves require "base64"
http.request :authorization, "Basic", Base64.strict_encode64("#{username}:#{password}") |
@sambostock Thanks for the feedback. Yes, this PR is not backward compatible with Faraday v2. The PR aims to suppress the annoying warnings, and I think we may need additional code changes for Faraday v2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faraday::Connection#set_authorization_header
has been removed from main, so it's not a long-term fix.
Would it be fruitful to try with Faraday 1.8.0, which came in the meantime? Perhaps not? lostisland/faraday@v1.7.1...v1.8.0 (Re-reading, I note that, yes |
@olleolleolle Thanks for sharing the new version. This PR seems still valid with Faraday 1.8.0. |
@ybiquitous Yeah, this PR 👍 excellent stuff. 1.0 + 2.0 compat may take another PR, and some trickery. |
Hi all, just a quick nudge to let you know that we've added a "how to do this in Faraday 1.x" section in the documentation. Regarding cross-supporting both Faraday 1.x and 2.x, I'm afraid at the moment there's no suggested way of doing it. I'm open to feedback/suggestions if you have any, but I agree this should be tackled on a separate PR |
@iMacTia Thank you. I've followed your advice and push the change c34a880, but the tests have failed:
Any advice? EDIT: When using with octokit.rb/lib/octokit/connection.rb Lines 105 to 118 in c34a880
|
@ybiquitous I was having a look myself and I'm finding it quite hard to understand what's going on. However, looking at the code pointed by the stacktrace I can see that a new connection is being initialised, with no request being fired until the end of the process. So I don't really understand how that can be possible. So far, the only thing I can think about is that this line is somehow injecting an already locked builder, but I'm having some really hard time following the code (and in particular usages of |
@iMacTia Thanks for the investigation. Maybe, the octokit.rb/lib/octokit/default.rb Lines 26 to 33 in d729c0d
The following change can reduce 556 failures to 46 failures on my localhost: --- a/lib/octokit/default.rb
+++ b/lib/octokit/default.rb
@@ -115,7 +115,7 @@ module Octokit
# from {MIDDLEWARE}
# @return [Faraday::RackBuilder or Faraday::Builder]
def middleware
- MIDDLEWARE
+ MIDDLEWARE.dup
end
# Default GitHub password for Basic Auth from ENV (Note: this change is not an essential solution)
|
Nice catch @ybiquitous 👏 ! It looks like a step in the right direction though. Somehow that same connection is being reused, causing new agents to fail after the first request gets processed 👍 |
Sure. I've pushed 1680bad. |
Thanks @ybiquitous, that was indeed useful, I think I found the underlying issue: octokit.rb/lib/octokit/client.rb Lines 135 to 138 in d1628eb
The Client initialiser sets instance variables based on the main Octokit module variables. This is quite convoluted, but |
@iMacTia Thank you so much! I've added octokit.rb/lib/octokit/client.rb Line 236 in d729c0d
EDIT: |
Only 4 failures left 🎉! |
@iMacTia Thank you. When I turned on the Faraday's logging as below, --- a/lib/octokit/connection.rb
+++ b/lib/octokit/connection.rb
@@ -106,6 +106,7 @@ module Octokit
http.headers[:accept] = default_media_type
http.headers[:content_type] = "application/json"
http.headers[:user_agent] = user_agent
+ http.response :logger
if basic_authenticated?
http.request :basic_auth, @login, @password
elsif token_authenticated? I got the following result. When using Using
Using
EDIT: The result above was produced by the |
@ybiquitous it's an issue with middleware order. When you use the deprecated I hope this makes sense, we're definitely getting close! |
@iMacTia Thanks! I understand it. 👍🏼 When I moved --- a/lib/octokit/connection.rb
+++ b/lib/octokit/connection.rb
@@ -115,6 +115,7 @@ module Octokit
elsif application_authenticated?
http.request :basic_auth, @client_id, @client_secret
end
+ http.response :logger
end
end
I got the following output.
The reason of the test failures seems to be a diff in the value of -Authorization: "token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+Authorization: "Token token=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"" |
Aha! Yes that's exactly how the http.request :authorization, 'token', @access_token I know, this is super-confusing. And exactly the reason why I decided to remove it in Faraday 2.x 🤦♂️ |
Thanks! I've pushed c7b5fa2 to fix the token failure. 😄 EDIT: Finally, we have only 1 failure: |
When following redirects, the
|
@ybiquitous so close! Checking the error it seems like this might also be a middleware order issue.
The expectation is that following a redirect, the So the stack looks like this:
When a 3xx response is received, the If the two middleware were swapped, then this wouldn't happen anymore. The reason this worked with the old implementation was that the header was previously added during the connection initialisation, rather than by a middleware during the request lifecycle |
@iMacTia Thanks. As you thought, the Is there a way to exclude the |
@ybiquitous the recommended way would be for the middleware to be in the right order, BUT there's another workaround. That means that instead of removing the authorisation header completely, you could set it to some placeholder value. |
My pleasure! I'm glad I could help ❤️ |
Thanks to everyone for your work and patience on this 💖 |
This fixes a warning: octokit/octokit.rb#1359
Run rails app:update Start process of porting CSS to Tailwind 3 Use propshaft instead of sprockets WIP Use esbuild not webpack Fix trailing whitespace lint error Update Dockerfile to Rails 3.0.3 Fix init.sql for mysql 8 Fix connecting to database Normalize quotes Enable yarn build in background Disable js watch Work Missing files Get icons working Allow importing manifest Use asset url helper Remove dynamic require Remove webpack-specific files Temporarily use local exercism config Temporarily use local exercism config Copy config items Update manifest Win Refactor code Remove unused define Update Change vendor prefix Update Enable watch mode for js Minify JS in production Minify CSS in production Remove unused code Remove webpack bin scripts Move listen gem out of development group Update manifest in background Ignore javascript config files Upgrade config to 0.81.0 Use .config dir Apply review comments Upgrade to Ruby 3.1.0 Update bundler version Fixes rubygems/rubygems#5234 Rename monitor_manifest to monitor-manifest Upgrade to Rails 7.0.1 Remove webpack references Exclude file Fix anycable Fix anycable Fix css name Remove webpacker helper references Fix passing of params to I18N Fix asset paths Fix i18n call Fix more tests Add .keep file for .config dir Add .keep file Fix esbuild Some tweaks (#2329) Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com> Fix timestamp test Fix old image_pack_url Fix path Use git version for mysql gem Remove image Update Setup Ruby workflow Add missing package Don't run tests serially Fix manifest import Don't use esbuild-jest Remove svg plugin Upate lockfile Add TODO Fix rails tests Build for browserslist Fix failing tests Fix failing tests Fix duplicate key exception in seeds.rb See https://blog.saeloun.com/2021/03/08/rails-6-1-adds-excluding-to-active-record-relation.html for the .excluding method Fix websockets Fix icon call Fix icons in notifications (#2333) * Fix icons in notifications * Fix more stuff Fix image url for blog post Sync blog and main docs in seeding Update octokit This fixes a warning: octokit/octokit.rb#1359 Fix deprecation warning Build test.js file Fix uri encode test Remove unused import Use test:prepare instead of assets:precompile Add empty string to tag.div Fix omniauth Write manifest JSON files in test helper Fix modal argument Enable esbuild splitting (#2342) * Enable esbuild splitting * Add comment Update migrations to 7.0 Fix CSS classes not inheriting correctly Add precision to datetime columns Fix invalid error icon Remove unused import Fix non-unique key Fix JS bug Moves highlighters CSS to postcss Remove socket configuration (#2341) * Member badge shouldn't use estimate for percentage awardees (#2330) * Remove socket configuration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Member badge shouldn't use estimate for percentage awardees (#2330) Don't consider wip prerequisites (#2344) * Don't consider wip prerequisites * Rename to learnable_concept_slugs Add timeouts to CI builds (#2331) * Add timeouts to CI builds Right now the builds are all stuck for some reason, clogging up the queues. They normal appear to be taking ~2-3 minutes, so a timeout of 30 minutes should be more than enough to prevent this issue in the future. * Add system tests & rubocup [skip ci] Set num_loc correctly when publishing a solution (#2260) * Set num_loc correctly when publishing a solution * DRY up publishing and publishing iteration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Fix typo in bug report modal (#2339) Add first draft of fundraising job role (#2337) * Add first draft of fundraising job role * Spelling * Improve * Tweaks from DJ * More tweaks * Add more * Tweaks * Tweaks * Final tweak Update setup-ruby action DRY up code around tooling files (#2257) * DRY up logic slightly * Add tests to verify editor files * Use proper directory * Fix representation file paths * DRY further (#2348) Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Allow sorting user solutions by most starred (#2238) * Allow sorting user solutions by num stars * Allow sorting user published solutions by most stars * Update system test * Fix sorting in test * Improve default of sorting * Fix many tests rails 7 rubocop (#2349) * Update rubocop gems * Format using rubocop * Add num_stars * Fix rubocop warning
Run rails app:update Start process of porting CSS to Tailwind 3 Use propshaft instead of sprockets WIP Use esbuild not webpack Fix trailing whitespace lint error Update Dockerfile to Rails 3.0.3 Fix init.sql for mysql 8 Fix connecting to database Normalize quotes Enable yarn build in background Disable js watch Work Missing files Get icons working Allow importing manifest Use asset url helper Remove dynamic require Remove webpack-specific files Temporarily use local exercism config Temporarily use local exercism config Copy config items Update manifest Win Refactor code Remove unused define Update Change vendor prefix Update Enable watch mode for js Minify JS in production Minify CSS in production Remove unused code Remove webpack bin scripts Move listen gem out of development group Update manifest in background Ignore javascript config files Upgrade config to 0.81.0 Use .config dir Apply review comments Upgrade to Ruby 3.1.0 Update bundler version Fixes rubygems/rubygems#5234 Rename monitor_manifest to monitor-manifest Upgrade to Rails 7.0.1 Remove webpack references Exclude file Fix anycable Fix anycable Fix css name Remove webpacker helper references Fix passing of params to I18N Fix asset paths Fix i18n call Fix more tests Add .keep file for .config dir Add .keep file Fix esbuild Some tweaks (#2329) Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com> Fix timestamp test Fix old image_pack_url Fix path Use git version for mysql gem Remove image Update Setup Ruby workflow Add missing package Don't run tests serially Fix manifest import Don't use esbuild-jest Remove svg plugin Upate lockfile Add TODO Fix rails tests Build for browserslist Fix failing tests Fix failing tests Fix duplicate key exception in seeds.rb See https://blog.saeloun.com/2021/03/08/rails-6-1-adds-excluding-to-active-record-relation.html for the .excluding method Fix websockets Fix icon call Fix icons in notifications (#2333) * Fix icons in notifications * Fix more stuff Fix image url for blog post Sync blog and main docs in seeding Update octokit This fixes a warning: octokit/octokit.rb#1359 Fix deprecation warning Build test.js file Fix uri encode test Remove unused import Use test:prepare instead of assets:precompile Add empty string to tag.div Fix omniauth Write manifest JSON files in test helper Fix modal argument Enable esbuild splitting (#2342) * Enable esbuild splitting * Add comment Update migrations to 7.0 Fix CSS classes not inheriting correctly Add precision to datetime columns Fix invalid error icon Remove unused import Fix non-unique key Fix JS bug Moves highlighters CSS to postcss Remove socket configuration (#2341) * Member badge shouldn't use estimate for percentage awardees (#2330) * Remove socket configuration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Member badge shouldn't use estimate for percentage awardees (#2330) Don't consider wip prerequisites (#2344) * Don't consider wip prerequisites * Rename to learnable_concept_slugs Add timeouts to CI builds (#2331) * Add timeouts to CI builds Right now the builds are all stuck for some reason, clogging up the queues. They normal appear to be taking ~2-3 minutes, so a timeout of 30 minutes should be more than enough to prevent this issue in the future. * Add system tests & rubocup [skip ci] Set num_loc correctly when publishing a solution (#2260) * Set num_loc correctly when publishing a solution * DRY up publishing and publishing iteration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Fix typo in bug report modal (#2339) Add first draft of fundraising job role (#2337) * Add first draft of fundraising job role * Spelling * Improve * Tweaks from DJ * More tweaks * Add more * Tweaks * Tweaks * Final tweak Update setup-ruby action DRY up code around tooling files (#2257) * DRY up logic slightly * Add tests to verify editor files * Use proper directory * Fix representation file paths * DRY further (#2348) Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Allow sorting user solutions by most starred (#2238) * Allow sorting user solutions by num stars * Allow sorting user published solutions by most stars * Update system test * Fix sorting in test * Improve default of sorting * Fix many tests rails 7 rubocop (#2349) * Update rubocop gems * Format using rubocop * Add num_stars * Fix rubocop warning
* Bump Gem to Rails 7, and switch to Ruby 3.0.3 Run rails app:update Start process of porting CSS to Tailwind 3 Use propshaft instead of sprockets WIP Use esbuild not webpack Fix trailing whitespace lint error Update Dockerfile to Rails 3.0.3 Fix init.sql for mysql 8 Fix connecting to database Normalize quotes Enable yarn build in background Disable js watch Work Missing files Get icons working Allow importing manifest Use asset url helper Remove dynamic require Remove webpack-specific files Temporarily use local exercism config Temporarily use local exercism config Copy config items Update manifest Win Refactor code Remove unused define Update Change vendor prefix Update Enable watch mode for js Minify JS in production Minify CSS in production Remove unused code Remove webpack bin scripts Move listen gem out of development group Update manifest in background Ignore javascript config files Upgrade config to 0.81.0 Use .config dir Apply review comments Upgrade to Ruby 3.1.0 Update bundler version Fixes rubygems/rubygems#5234 Rename monitor_manifest to monitor-manifest Upgrade to Rails 7.0.1 Remove webpack references Exclude file Fix anycable Fix anycable Fix css name Remove webpacker helper references Fix passing of params to I18N Fix asset paths Fix i18n call Fix more tests Add .keep file for .config dir Add .keep file Fix esbuild Some tweaks (#2329) Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com> Fix timestamp test Fix old image_pack_url Fix path Use git version for mysql gem Remove image Update Setup Ruby workflow Add missing package Don't run tests serially Fix manifest import Don't use esbuild-jest Remove svg plugin Upate lockfile Add TODO Fix rails tests Build for browserslist Fix failing tests Fix failing tests Fix duplicate key exception in seeds.rb See https://blog.saeloun.com/2021/03/08/rails-6-1-adds-excluding-to-active-record-relation.html for the .excluding method Fix websockets Fix icon call Fix icons in notifications (#2333) * Fix icons in notifications * Fix more stuff Fix image url for blog post Sync blog and main docs in seeding Update octokit This fixes a warning: octokit/octokit.rb#1359 Fix deprecation warning Build test.js file Fix uri encode test Remove unused import Use test:prepare instead of assets:precompile Add empty string to tag.div Fix omniauth Write manifest JSON files in test helper Fix modal argument Enable esbuild splitting (#2342) * Enable esbuild splitting * Add comment Update migrations to 7.0 Fix CSS classes not inheriting correctly Add precision to datetime columns Fix invalid error icon Remove unused import Fix non-unique key Fix JS bug Moves highlighters CSS to postcss Remove socket configuration (#2341) * Member badge shouldn't use estimate for percentage awardees (#2330) * Remove socket configuration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Member badge shouldn't use estimate for percentage awardees (#2330) Don't consider wip prerequisites (#2344) * Don't consider wip prerequisites * Rename to learnable_concept_slugs Add timeouts to CI builds (#2331) * Add timeouts to CI builds Right now the builds are all stuck for some reason, clogging up the queues. They normal appear to be taking ~2-3 minutes, so a timeout of 30 minutes should be more than enough to prevent this issue in the future. * Add system tests & rubocup [skip ci] Set num_loc correctly when publishing a solution (#2260) * Set num_loc correctly when publishing a solution * DRY up publishing and publishing iteration Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Fix typo in bug report modal (#2339) Add first draft of fundraising job role (#2337) * Add first draft of fundraising job role * Spelling * Improve * Tweaks from DJ * More tweaks * Add more * Tweaks * Tweaks * Final tweak Update setup-ruby action DRY up code around tooling files (#2257) * DRY up logic slightly * Add tests to verify editor files * Use proper directory * Fix representation file paths * DRY further (#2348) Co-authored-by: Jeremy Walker <jez.walker@gmail.com> Allow sorting user solutions by most starred (#2238) * Allow sorting user solutions by num stars * Allow sorting user published solutions by most stars * Update system test * Fix sorting in test * Improve default of sorting * Fix many tests rails 7 rubocop (#2349) * Update rubocop gems * Format using rubocop * Add num_stars * Fix rubocop warning * Remove active storage migrations * Rename .manifest.json.d.ts to manifest.json.d.ts * Make monitor manifest a 1-time opp in CI * Fix bug in test helper * Call super * Fix tests * Seperate generate js config into its own file * Fix production nodejs build * Fix production rails dockerfile * Fix production rails dockerfile * Fix assets sync * Fix production docker build * Workaround for NODE_ENV=production yarn install not installing devDependencies * Use RAILS_ENV=production * Fix failing test * Only deploy website to website-staging Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
## What Bumps Octokit version to 4.21 ## Why This should remove warnings issued by recent versions of Faraday: ``` WARNING: `Faraday::Connection#authorization` is deprecated; it will be removed in version 2.0. While initializing your connection, use `#request(:authorization, ...)` instead. See https://lostisland.github.io/faraday/middleware/authentication for more usage info. ``` See octokit/octokit.rb#1359 ## How Simple gemspec bump. Note that there are [some murmurings about compatibility with GitHub Enterprise](octokit/octokit.rb#1391) with `v 4.22`, so for now have pointed it to `4.21`.
Close #1357