-
Notifications
You must be signed in to change notification settings - Fork 1.2k
states:GetExecutionHistory fails in ruby3.4 Lambda environment #3231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening an issue. The error appears to be in the JSON gem. Do you have a full SDK stack trace? You may want to consider opening an issue with the json maintainers. You can also try adding gem |
@mullermp thanks that makes sense. I wonder if this is instead a bug to file with the Lambda maintainers — maybe the |
I'm not sure if it's a lambda issue either. What part of the code is calling .encode()? Can we try to get a root cause of why that can't be parsed with the json gem? |
Here's a sample SAM template that can replicate the issue (forgive the overly-permissive IAM policy): # template.yml
---
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: AWS Ruby SDK Test
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Architectures:
- arm64
CodeUri: .
Description: Test aws-sdk-states
Environment:
Variables:
STATE_MACHINE_ARN: !Ref StateMachine
Handler: index.handler
Policies:
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action: states:*
Resource: "*"
Runtime: ruby3.4
StateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Definition:
QueryLanguage: JSONata
StartAt: Pass
States:
Pass:
Type: Pass
End: true
Output:
utf8: — # emdash character And here's my Gemfile + index.rb: # Gemfile
source 'https://rubygems.org'
gem 'aws-sdk-states' # index.rb
require 'aws-sdk-states'
STATES = Aws::States::Client.new
STATE_MACHINE_ARN = ENV['STATE_MACHINE_ARN']
def handler(event:, context:)
execution_arn = STATES.list_executions(state_machine_arn: STATE_MACHINE_ARN).executions.first.execution_arn
STATES.get_execution_history(execution_arn:)
end And here is the result of invoking the Lambda: {
"errorMessage": "\"\\xE2\" on US-ASCII",
"errorType": "Function<Encoding::InvalidByteSequenceError>",
"stackTrace": [
"/var/lang/lib/ruby/3.4.0/json/common.rb:221:in 'String#encode'",
"/var/lang/lib/ruby/3.4.0/json/common.rb:221:in 'JSON::Ext::Parser.parse'",
"/var/lang/lib/ruby/3.4.0/json/common.rb:221:in 'JSON.parse'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/json_engine.rb:10:in 'Aws::Json::JsonEngine.load'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json.rb:43:in 'Aws::Json.load'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/parser.rb:22:in 'Aws::Json::Parser#parse'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/handler.rb:65:in 'Aws::Json::Handler#parse_body'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/handler.rb:37:in 'Aws::Json::Handler#parse_response'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/handler.rb:14:in 'block in Aws::Json::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/response.rb:52:in 'block in Seahorse::Client::Response#on'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/http/response.rb:146:in 'block in Seahorse::Client::Http::Response#on_success'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/http/response.rb:173:in 'block in Seahorse::Client::Http::Response#listener'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/http/response.rb:137:in 'Seahorse::Client::Http::Response#on_done'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/http/response.rb:144:in 'Seahorse::Client::Http::Response#on_success'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/response.rb:51:in 'Seahorse::Client::Response#on'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/json/handler.rb:14:in 'Aws::Json::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/recursion_detection.rb:18:in 'Aws::Plugins::RecursionDetection::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-states-1.87.0/lib/aws-sdk-states/plugins/endpoints.rb:43:in 'block in Aws::States::Plugins::Endpoints::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/user_agent.rb:69:in 'Aws::Plugins::UserAgent.metric'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-states-1.87.0/lib/aws-sdk-states/plugins/endpoints.rb:57:in 'Aws::States::Plugins::Endpoints::Handler#with_metrics'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-states-1.87.0/lib/aws-sdk-states/plugins/endpoints.rb:43:in 'Aws::States::Plugins::Endpoints::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/endpoint_discovery.rb:84:in 'Aws::Plugins::EndpointDiscovery::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/plugins/endpoint.rb:46:in 'Seahorse::Client::Plugins::Endpoint::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/param_validator.rb:26:in 'Aws::Plugins::ParamValidator::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/plugins/raise_response_errors.rb:16:in 'Seahorse::Client::Plugins::RaiseResponseErrors::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/checksum_algorithm.rb:169:in 'Aws::Plugins::ChecksumAlgorithm::OptionHandler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:16:in 'Aws::Plugins::JsonvalueConverter::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/invocation_id.rb:16:in 'Aws::Plugins::InvocationId::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in 'Aws::Plugins::IdempotencyToken::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/param_converter.rb:26:in 'Aws::Plugins::ParamConverter::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/plugins/request_callback.rb:89:in 'Seahorse::Client::Plugins::RequestCallback::OptionHandler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/response_paging.rb:12:in 'Aws::Plugins::ResponsePaging::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/plugins/response_target.rb:24:in 'Seahorse::Client::Plugins::ResponseTarget::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/telemetry.rb:39:in 'block in Aws::Plugins::Telemetry::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/telemetry/no_op.rb:29:in 'Aws::Telemetry::NoOpTracer#in_span'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/telemetry.rb:53:in 'Aws::Plugins::Telemetry::Handler#span_wrapper'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/aws-sdk-core/plugins/telemetry.rb:39:in 'Aws::Plugins::Telemetry::Handler#call'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-core-3.219.0/lib/seahorse/client/request.rb:72:in 'Seahorse::Client::Request#send_request'",
"/var/runtime/ruby/3.4.0/gems/aws-sdk-states-1.87.0/lib/aws-sdk-states/client.rb:1721:in 'Aws::States::Client#get_execution_history'",
"/var/task/index.rb:8:in 'Object#handler'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric/lambda_handler.rb:28:in 'LambdaHandler#call_handler'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:86:in 'AwsLambdaRIC::LambdaRunner#run_user_code'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:64:in 'AwsLambdaRIC::LambdaRunner#start_runtime_loop'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:47:in 'AwsLambdaRIC::LambdaRunner#run'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:219:in 'AwsLambdaRIC::Bootstrap#bootstrap_handler'",
"/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:201:in 'AwsLambdaRIC::Bootstrap#start'",
"/var/runtime/index.rb:4:in '<main>'"
]
} |
This issue looks very familiar to what I encountered last year with the I will test with your reproduction to see if I can replicate the error. In the mean time, have you tried using a different json engine like |
After adding the |
Describe the bug
In the Lambda
ruby3.4
runtime using the latest version of theaws-sdk-states
gem, thestates:GetExecutionHistory
encounters a JSON parsing error if the execution history contains unicode characters.Regression Issue
Expected Behavior
Aws::States::Client.new.get_execution_history(execution_arn: 'arn:aws...')
should succeedCurrent Behavior
When a Step Function state machine's execution history contains an emdash (Unicode U+2014) the Ruby SDK throws an error parsing the JSON response.
Reproduction Steps
docker run --rm -it --entrypoint=bash public.ecr.aws/lambda/ruby
gem install aws-sdk-states
irb
Aws::States::Client.new.get_execution_history(execution_arn: 'arn:aws:...')
Possible Solution
No response
Additional Information/Context
No response
Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk-states
Environment details (Version of Ruby, OS environment)
Lambda ruby3.4
The text was updated successfully, but these errors were encountered: