Skip to content

aws-sdk-cloudwatch 1.126.0 breaks stubbing #3325

Description

@pkopac

Describe the bug

Upgrading aws-sdk-cloudwatch gem from 1.125.0 to 1.126.0 breaks unit testing with this error:

     # --- Caused by: ---
     # JSON::ParserError:
     #   Empty input (after ) at line 1, column 1 [parse.c:1058] in '?hMessages?qMetricDataResults??bIdfSomeIdeLabeleLabeljTimestamps???A?O?~??fValues??@^?/??wjStatusCodehCompletehMessages?

This has something to do with binary serialization/protocol, which the changelog mentions, so I think it's a regression.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I expect the default behavior to be JSON serialization. And if not that, then the library should at least handle stubbing in backwards-compatible way. Documentation doesn't mention anything about it AFAIK.

Current Behavior

The library tries to parse binary-serialized response as JSON response.

     Aws::Json::ParseError:
       Empty input (after ) at line 1, column 1 [parse.c:1058] in '?hMessages?qMetricDataResults??bIdfSomeIdeLabeleLabeljTimestamps???A?O?~??fValues??@^?/??wjStatusCodehCompletehMessages?
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/oj_engine.rb:22:in 'Aws::Json::OjEngine.load'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json.rb:43:in 'Aws::Json.load'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/parser.rb:22:in 'Aws::Json::Parser#parse'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/handler.rb:65:in 'Aws::Json::Handler#parse_body'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/handler.rb:37:in 'Aws::Json::Handler#parse_response'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/handler.rb:14:in 'block in Aws::Json::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/response.rb:52:in 'block in Seahorse::Client::Response#on'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/http/response.rb:146:in 'block in Seahorse::Client::Http::Response#on_success'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/http/response.rb:173:in 'block in Seahorse::Client::Http::Response#listener'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/http/response.rb:137:in 'Seahorse::Client::Http::Response#on_done'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/http/response.rb:144:in 'Seahorse::Client::Http::Response#on_success'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/response.rb:51:in 'Seahorse::Client::Response#on'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/json/handler.rb:14:in 'Aws::Json::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/recursion_detection.rb:18:in 'Aws::Plugins::RecursionDetection::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/stub_responses.rb:72:in 'Aws::Plugins::StubResponses::ApiRequestsHandler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-cloudwatch-1.126.0/lib/aws-sdk-cloudwatch/plugins/endpoints.rb:43:in 'block in Aws::CloudWatch::Plugins::Endpoints::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/user_agent.rb:92:in 'Aws::Plugins::UserAgent.metric'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-cloudwatch-1.126.0/lib/aws-sdk-cloudwatch/plugins/endpoints.rb:57:in 'Aws::CloudWatch::Plugins::Endpoints::Handler#with_metrics'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-cloudwatch-1.126.0/lib/aws-sdk-cloudwatch/plugins/endpoints.rb:43:in 'Aws::CloudWatch::Plugins::Endpoints::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/endpoint_discovery.rb:84:in 'Aws::Plugins::EndpointDiscovery::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/plugins/endpoint.rb:46:in 'Seahorse::Client::Plugins::Endpoint::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/param_validator.rb:26:in 'Aws::Plugins::ParamValidator::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/plugins/raise_response_errors.rb:16:in 'Seahorse::Client::Plugins::RaiseResponseErrors::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/checksum_algorithm.rb:169:in 'Aws::Plugins::ChecksumAlgorithm::OptionHandler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:16:in 'Aws::Plugins::JsonvalueConverter::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/invocation_id.rb:16:in 'Aws::Plugins::InvocationId::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in 'Aws::Plugins::IdempotencyToken::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/param_converter.rb:26:in 'Aws::Plugins::ParamConverter::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/response_paging.rb:12:in 'Aws::Plugins::ResponsePaging::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/plugins/response_target.rb:24:in 'Seahorse::Client::Plugins::ResponseTarget::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/telemetry.rb:39:in 'block in Aws::Plugins::Telemetry::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/telemetry/no_op.rb:29:in 'Aws::Telemetry::NoOpTracer#in_span'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/telemetry.rb:53:in 'Aws::Plugins::Telemetry::Handler#span_wrapper'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/aws-sdk-core/plugins/telemetry.rb:39:in 'Aws::Plugins::Telemetry::Handler#call'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-core-3.239.2/lib/seahorse/client/request.rb:72:in 'Seahorse::Client::Request#send_request'
     # /home/developer/.gem/ruby/3.4.0/gems/aws-sdk-cloudwatch-1.126.0/lib/aws-sdk-cloudwatch/client.rb:1891:in 'Aws::CloudWatch::Client#get_metric_data'
... application stack trace...

Reproduction Steps

Here's a simplified test case for RSpec:

  it 'replicates issue' do
    Aws::CloudWatch::Client.new(stub_responses: true).stub_responses(
      :get_metric_data, lambda { |_context|
                          { messages: [],
                            next_token: nil,
                            metric_data_results: [{ id: 'SomeId', label: 'Label',
                                                    timestamps: [1.day.ago], values: [123.456], status_code: 'Complete', messages: [] }] }
                        }
    )
    # Simplified production code
    query = [{ id: 'SomeId',
               metric_stat: {
                 metric: { namespace: 'AWS/RDS', metric_name: 'ReadIOPS', dimensions: [{ name: 'DBInstanceIdentifier', value: 'instance_name' }] },
                 period: 1.week.seconds, stat: 'Average', unit: 'Count/Second'
               } }]
    result = Aws::CloudWatch::Client.new.get_metric_data(
      metric_data_queries: query,
      start_time: 1.week.seconds.ago, end_time: Time.zone.now
    ).metric_data_results
    # Test expects no error and the value to be present.
    expect(result.first.values.first).to eq(123.456)
  end

Possible Solution

Stubbing should be made compatible.

Additional Information/Context

No response

Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version

aws-sdk-cloudwatch 1.126.0

Environment details (Version of Ruby, OS environment)

ruby 3.4.6, Linux

Activity

  1. added
    bugThis issue is a bug.
    needs-triageThis issue or PR still needs to be triaged.
    on Dec 15, 2025
  2. changed the title [-]1.126.0 breaks stubbing[/-] [+]aws-sdk-cloudwatch 1.126.0 breaks stubbing[/+] on Dec 15, 2025
  3. jterapin commented on Dec 15, 2025

    @jterapin
    Contributor

    Hi! Thanks for submitting the issue and we will be taking a look. At glance, I believe it is due to the service changing from underlying parser from query to json.

  4. added
    investigatingIssue is being investigated
    and removed
    needs-triageThis issue or PR still needs to be triaged.
    on Dec 15, 2025
  5. github-actions commented on Dec 16, 2025

    @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.

  6. richardwang1124 commented on Dec 16, 2025

    @richardwang1124
    Contributor

    The fix will be going out in today's release. I can give you the gem version to use once the release is finished.

    Update: release succeeded. Using aws-sdk-core 3.240.0 should resolve your issue.

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

    bugThis issue is a bug.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions