Skip to content

Conversation

Copy link

Copilot AI commented Dec 2, 2025

Fixes omniauth#160 - NoMethodError: undefined method 'expired?' for nil:NilClass when OAuth2 authentication fails and build_access_token returns nil.

Changes

  • Nil access_token handling: Guard expired? call and fail gracefully with :invalid_credentials instead of crashing
  • OAuth2 error namespacing: Fix OAuth2::TimeoutError and OAuth2::ConnectionError constant lookup with :: prefix

Example

Before:

self.access_token = build_access_token
self.access_token = access_token.refresh! if access_token.expired?  # crashes if nil
super

After:

self.access_token = build_access_token
if access_token
  self.access_token = access_token.refresh! if access_token.expired?
  super
else
  fail!(:invalid_credentials, CallbackError.new(:invalid_credentials, "Failed to build access token"))
end

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • coveralls.io
    • Triggering command: /usr/bin/ruby3.2 ruby3.2 /home/REDACTED/work/omniauth-oauth2/omniauth-oauth2/vendor/bundle/ruby/3.2.0/bin/rspec (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

can you fix this issue


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 2, 2025 21:59
Co-authored-by: jessieay <601515+jessieay@users.noreply.github.com>
Co-authored-by: jessieay <601515+jessieay@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue in the code Fix NoMethodError when access_token is nil in callback_phase Dec 2, 2025
Copilot AI requested a review from jessieay December 2, 2025 22:06
Copilot finished work on behalf of jessieay December 2, 2025 22:06
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.

NoMethodError (undefined method `expired?' for nil:NilClass)

2 participants