Skip to content

Undefined method `[]' for Rack::Request instance with Rack 3.1.7 #1135

@adifsgaid

Description

@adifsgaid

Please complete all sections.

Configuration

  • Provider Gem: omniauth-twitter
  • Ruby Version: 3.3.2
  • Framework: rails
  • Platform:
    • Host OS: macOS Sonoma 14.5
    • Docker Version: 4.32.0
    • Docker Image: [registry.docker.com/library/ruby:3.3.2-slim]
    • Container OS:
      PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
      NAME="Debian GNU/Linux"
      VERSION_ID="12"
      VERSION="12 (bookworm)"
      VERSION_CODENAME=bookworm
      ID=debian
      HOME_URL="https://www.debian.org/"
      SUPPORT_URL="https://www.debian.org/support"
      BUG_REPORT_URL="https://bugs.debian.org/"

Description

When using OmniAuth 2.1.2 with Rack 3.1.7, we encountered an error during the Twitter OAuth callback phase. The error suggests that there's an incompatibility between OmniAuth and Rack 3.x versions.

Expected Behavior

The OAuth callback should complete successfully, allowing the user to authenticate via Twitter.

Actual Behavior

The callback fails with a NoMethodError, indicating that the [] method is undefined for the Rack::Request instance.

Failing here.

Steps to Reproduce

  1. Set up a Rails application with Devise and OmniAuth for Twitter authentication.
  2. Configure the Twitter OAuth callback.
  3. Attempt to authenticate with Twitter.
  4. The authentication process fails during the callback phase.
  5. make sure you have the following rack version 3.1.7

Environment

  • Rails version: 7.1.3.4
  • OmniAuth version: 2.1.2
  • omniauth-twitter version: 1.4.0
  • Rack version: 3.1.7
  • Devise version: 4.9.3

This are the gems I have configured with other providers as well, all seem working fine except for the twitter gem:

  • gem 'omniauth', '~> 2.1'
  • gem 'omniauth-facebook'
  • gem 'omniauth-github'
  • gem 'omniauth-google-oauth2'
  • gem 'omniauth-microsoft_graph'
  • gem 'omniauth-twitter', '~> 1.4.0'
  • gem 'omniauth-rails_csrf_protection', '~> 1.0'

Workaround

Downgrading Rack to version 2.2.4 resolves the issue. The authentication process works as expected with this older version of Rack.

Additional Context

This error seems to be related to changes in the Rack API between versions 2.x and 3.x. It appears that OmniAuth is trying to use a method or access data from the Rack::Request object in a way that's no longer supported in Rack 3.x.

Possible Solution

The OmniAuth gem may need to be updated to accommodate the changes in Rack 3.x, particularly in how it interacts with the Rack::Request object during the OAuth callback phase.

Question

Is there a planned update for OmniAuth to support Rack 3.x? If so, is there an estimated timeline for this release?

Thank you for your attention to this issue. Let me know if you need any additional information or if there are any specific tests I can run to help diagnose this problem further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions