{"record":{"id":"f8d17274c326f07c","repo":"lostisland/faraday","slug":"an-attempt-to-run-a-request-with-a-faraday-connec","errorCode":null,"errorMessage":"An attempt to run a request with a Faraday::Connection without adapter has been made.\nPlease set Faraday.default_adapter or provide one when initializing the connection.\nFor more info, check https://lostisland.github.io/faraday/usage/.","messagePattern":"An attempt to run a request with a Faraday::Connection without adapter has been made\\.\nPlease set Faraday\\.default_adapter or provide one when initializing the connection\\.\nFor more info, check https://lostisland\\.github\\.io/faraday/usage/\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"lib/faraday/rack_builder.rb","lineNumber":230,"sourceCode":"      Env.new(request.http_method, request.body, exclusive_url,\n              request.options, request.headers, connection.ssl,\n              connection.parallel_manager)\n    end\n\n    private\n\n    def raise_if_locked\n      raise StackLocked, LOCK_ERR if locked?\n    end\n\n    def raise_if_adapter(klass)\n      return unless klass <= Faraday::Adapter\n\n      raise 'Adapter should be set using the `adapter` method, not `use`'\n    end\n\n    def ensure_adapter!\n      raise MISSING_ADAPTER_ERROR unless @adapter\n    end\n\n    def adapter_set?\n      !@adapter.nil?\n    end\n\n    def use_symbol(mod, key, ...)\n      use(mod.lookup_middleware(key), ...)\n    end\n\n    def assert_index(index)\n      idx = index.is_a?(Integer) ? index : @handlers.index(index)\n      raise \"No such handler: #{index.inspect}\" unless idx\n\n      idx\n    end\n  end\nend","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/lostisland/faraday/blob/b25b1b26ccef34b1460b0267115be238ca758087/lib/faraday/rack_builder.rb#L212-L248","documentation":"The adapter is the terminal handler that performs the actual HTTP call, and RackBuilder#ensure_adapter! raises MISSING_ADAPTER_ERROR from build_response when @adapter is nil. RackBuilder#build normally appends Faraday.default_adapter automatically unless one was set, so in practice this error means Faraday.default_adapter was nil at connection-creation time — either explicitly cleared (adapter gems' test suites do this) or set to nil by app boot code — or the adapter was never configured in a manually built stack.","triggerScenarios":"Running Faraday.default_adapter = nil (common in specs for adapter gems) and then issuing a real request; app or gem code assigning Faraday.default_adapter = nil to 'force explicit configuration' and forgetting one connection; building a connection whose block raises before reaching the adapter line, leaving the stack half-configured; swapping adapters at runtime via builder manipulation that removes the adapter.","commonSituations":"Upgrading to Faraday 1.0+ where an adapter became mandatory and implicit fallbacks were removed; test environments that mutate the global Faraday.default_adapter and leak into other tests; code copied from adapter-gem specs into production; multi-tenant apps configuring Faraday defaults per-request and racing.","solutions":["Set an explicit adapter in the connection block: Faraday.new(url) { |b| b.adapter :net_http } — this is the documented, env-independent fix.","Restore the default at boot: Faraday.default_adapter = :net_http (and ensure the adapter gem, e.g. faraday-net_http, is in the bundle for Faraday 2.x).","Audit test helpers that set Faraday.default_adapter = nil and reset it in an ensure/around hook so it cannot leak into code that makes real requests.","If you configure the adapter conditionally, verify conn.builder.adapter_set? before the first request and fail fast with your own message."],"exampleFix":"# before\nFaraday.default_adapter = nil # leaked from a test helper\nconn = Faraday.new('https://api.example.com')\nconn.get('/ping')\n# => An attempt to run a request with a Faraday::Connection without adapter has been made.\n\n# after\nconn = Faraday.new('https://api.example.com') do |b|\n  b.request :url_encoded\n  b.adapter :net_http # explicit, immune to default_adapter state\nend\nconn.get('/ping')","handlingStrategy":"validation","validationCode":"raise 'no adapter configured' unless conn.builder.adapter_set?\nconn.get('/ping')","typeGuard":"def connection_runnable?(conn)\n  conn.builder.adapter_set?\nend","tryCatchPattern":"begin\n  conn.get('/ping')\nrescue RuntimeError => e\n  raise unless e.message.include?('without adapter')\n  conn.adapter :net_http # or rebuild the connection with an explicit adapter\n  conn.get('/ping')\nend","preventionTips":["Always declare the adapter explicitly in the Faraday.new block; do not rely on Faraday.default_adapter.","Reset Faraday.default_adapter in ensure/around hooks of tests that set it to nil, so the mutation cannot leak.","Verify faraday-net_http (or your adapter gem) is in the Gemfile on Faraday 2.x before relying on the default."],"tags":["ruby","faraday","adapter","configuration","connection-setup","faraday-2"],"backgroundTag":"missing-adapter-configuration","analyzedSha":"b25b1b26ccef34b1460b0267115be238ca758087","analyzedAt":"2026-08-21T19:43:20.220Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}