Skip to content

stub_responses raises ArgumentError with mocha loaded since aws-sdk-core 3.270.0 #3503

Closed as duplicate

Description

@mortik

Describe the bug

Since aws-sdk-core 3.270.0, Client#stub_responses raises ArgumentError whenever mocha is loaded.

3.270.0 changed Seahorse::Client::Configuration so it no longer generates a real Struct, and options are now answered through method_missing (seahorse/client/configuration.rb). Mocha mixes Mocha::ObjectMethods#stubs(stubbed_methods_vs_return_values) into every object, so @config.stubs in Aws::ClientStubs#apply_stubs (client_stubs.rb:238) resolves to mocha's real method instead of reaching method_missing. It is called with no arguments and raises.

Any Rails/Minitest suite that uses mocha and stub_responses: true breaks on upgrade. 3.268.0 works.

Expected Behavior

stub_responses stores the stub regardless of methods other libraries define on Object, as it does on 3.268.0.

Current Behavior

ArgumentError: wrong number of arguments (given 0, expected 1)
  mocha-3.1.0/lib/mocha/object_methods.rb:134:in 'Mocha::ObjectMethods#stubs'
  aws-sdk-core-3.271.0/lib/aws-sdk-core/client_stubs.rb:238:in 'block in Aws::ClientStubs#apply_stubs'
  aws-sdk-core-3.271.0/lib/aws-sdk-core/client_stubs.rb:237:in 'Thread::Mutex#synchronize'
  aws-sdk-core-3.271.0/lib/aws-sdk-core/client_stubs.rb:237:in 'Aws::ClientStubs#apply_stubs'
  aws-sdk-core-3.271.0/lib/aws-sdk-core/client_stubs.rb:163:in 'Aws::ClientStubs#stub_responses'

Reproduction Steps

gem "aws-sdk-core", "3.271.0" # same on 3.270.0
require "aws-sdk-s3"
require "mocha/object_methods"
Object.include(Mocha::ObjectMethods) # what mocha/minitest does

client = Aws::S3::Client.new(stub_responses: true, region: "us-east-1")
client.stub_responses(:list_objects_v2, {contents: []})
# => ArgumentError: wrong number of arguments (given 0, expected 1)

Possible Solution

Read config values in ClientStubs via @config[:stubs] / @config[:stubs_mutex] (or otherwise avoid dispatching option names that collide with methods defined on Object), or define real reader methods on the configuration object again.

Gem name and its version

aws-sdk-core 3.270.0, 3.271.0 (aws-sdk-s3 1.243.0)

Environment details

Ruby 4.0.9, mocha 3.1.0, minitest 6.1.0, Rails 8.1, macOS and Linux (CI)

🤖

Activity

  1. dscpinheiro commented on Nov 20, 2026

    @dscpinheiro
    Contributor

    This seems to be the same issue as #3501 (we already have a PR to address it - #3502)

  2. added
    bug
    on Nov 20, 2026
  3. added
    duplicate
    on Nov 20, 2026
  4. jterapin commented on Nov 20, 2026

    @jterapin
    Contributor

    Since this is a duplicate, I will be closing this issue so please track the latest updates in this issue #3501

  5. github-actions commented on Nov 20, 2026

    @github-actions

    This issue is now closed. Comments on closed issues are hard for our team to see.
    If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugduplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions