Skip to content

KeyError: key not found: :status #1629

@Vpatel1093

Description

@Vpatel1093

Running into this error after upgrading from 2.13.1 to 2.13.2

Seems related to this: https://github.com/lostisland/faraday/pull/1628/files#diff-c5f031a4be2bbda4d7befb7c1604ffee77d3bc86038f280aca9b14f1fc00350e

App code:
MyClient.new.create_user(sign_up_data)

class MyClient
    attr_reader :base_url

    def initialize(base_url)
      @base_url = base_url
    end

    def create_user(params)
      connection.post('registrations', params)
    end

    def connection
      @connection ||= build_connection
    end

    private

    # :reek:FeatureEnvy, :reek:TooManyStatements
    def build_connection
      Faraday.new(options) do |config|
        config.use Signature
        config.request :json
        config.response :json, preserve_raw: true
        config.response :raise_error
        config.response :logger, Rails.logger, { bodies: true, headers: true, log_level: :debug }
      end
    end

    def options
      {
        request: {
          open_timeout: 5,
          read_timeout: 15,
          write_timeout: 15
        },
        url: base_url
      }
    end
end

Stacktrace:

KeyError: key not found: :status

  0) RegistrationsController POST reate when Root Central has an error when Root Central has a non-JSON error renders the registration page with a default message
     Failure/Error: RootSDK::RootCentral::Client.new.create_user(sign_up_data)

     KeyError:
       key not found: :status
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/faraday-2.13.2/lib/faraday/error.rb:85:in 'fetch'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/faraday-2.13.2/lib/faraday/error.rb:85:in 'exc_msg_and_response'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/faraday-2.13.2/lib/faraday/error.rb:73:in 'exc_msg_and_response!'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/faraday-2.13.2/lib/faraday/error.rb:12:in 'initialize'
     > ./app/controllers/registrations_controller.rb:11:in 'create'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/ddtrace-1.23.3/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb:105:in 'process_action'
     > ./app/controllers/application_controller.rb:15:in 'set_time_zone'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/turbo-rails-2.0.12/lib/turbo-rails.rb:24:in 'with_request_id'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/turbo-rails-2.0.12/app/controllers/concerns/turbo/request_id_tracking.rb:10:in 'turbo_tracking_request_id'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/react-rails-2.7.1/lib/react/rails/controller_lifecycle.rb:31:in 'use_react_component_helper'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/audited-5.8.0/lib/audited/sweeper.rb:16:in 'around'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/audited-5.8.0/lib/audited/sweeper.rb:16:in 'around'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/actiontext-7.0.8.7/lib/action_text/rendering.rb:20:in 'with_renderer'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/actiontext-7.0.8.7/lib/action_text/engine.rb:69:in 'block (4 levels) in <class:Engine>'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/omniauth-2.1.3/lib/omniauth/strategy.rb:202:in 'call!'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/omniauth-2.1.3/lib/omniauth/strategy.rb:169:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-attack-6.7.0/lib/rack/attack.rb:127:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/exception_notification-4.6.0/lib/exception_notification/rack.rb:49:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/warden-1.2.9/lib/warden/manager.rb:36:in 'block in call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/warden-1.2.9/lib/warden/manager.rb:34:in 'catch'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/warden-1.2.9/lib/warden/manager.rb:34:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/tempfile_reaper.rb:15:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/etag.rb:27:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/conditional_get.rb:40:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/head.rb:12:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/session/abstract/id.rb:266:in 'context'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/session/abstract/id.rb:260:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/ddtrace-1.23.3/lib/datadog/tracing/contrib/rails/middlewares.rb:19:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/railties-7.0.8.7/lib/rails/rack/logger.rb:40:in 'call_app'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/railties-7.0.8.7/lib/rails/rack/logger.rb:25:in 'block in call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/semantic_logger-4.16.1/lib/semantic_logger/base.rb:190:in 'block in tagged'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/semantic_logger-4.16.1/lib/semantic_logger/semantic_logger.rb:356:in 'tagged'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/semantic_logger-4.16.1/lib/semantic_logger/base.rb:202:in 'tagged'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/railties-7.0.8.7/lib/rails/rack/logger.rb:25:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/method_override.rb:24:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/runtime.rb:22:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-2.2.17/lib/rack/sendfile.rb:110:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/ddtrace-1.23.3/lib/datadog/tracing/contrib/rack/middlewares.rb:109:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/railties-7.0.8.7/lib/rails/engine.rb:530:in 'call'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-test-2.2.0/lib/rack/test.rb:360:in 'process_request'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rack-test-2.2.0/lib/rack/test.rb:153:in 'request'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/integration.rb:16:in 'block (2 levels) in <module:Integration>'
     > ./spec/requests/registrations_controller_spec.rb:21:in 'block (3 levels) in <main>'
     > ./spec/requests/registrations_controller_spec.rb:89:in 'block (5 levels) in <main>'
     > ./spec/rails_helper.rb:99:in 'block (3 levels) in <top (required)>'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:30:in 'cleaning'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in 'block (2 levels) in cleaning'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in 'cleaning'
     > ./spec/rails_helper.rb:99:in 'block (2 levels) in <top (required)>'
     > /Users/root/.rvm/gems/ruby-3.2.8/gems/webmock-3.25.1/lib/webmock/rspec.rb:39:in 'block (2 levels) in <main>'

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