localstack icon indicating copy to clipboard operation
localstack copied to clipboard

bug: StepFunction S3 GetObject fails with "cannot pickle '_io.BufferedReader' object"

Open marc2982 opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

Hi,

Im triggering a step function on S3 file upload. The state machine then calls GetObject to get the object and in the future process it. The trigger works perfectly but the GetObject fails.

Looking in the localstack web view, the file seems to be uploaded correctly.

Key Last Modified Size
test1.xml 2024-02-07 14:45:00 2746

Step function:

{
  "Comment": "A description of my state machine",
  "StartAt": "GetObject",
  "States": {
    "GetObject": {
      "Type": "Task",
      "End": true,
      "Parameters": {
        "Bucket.$": "$.detail.bucket.name",
        "Key.$": "$.detail.object.key"
      },
      "Resource": "arn:aws:states:::aws-sdk:s3:getObject"
    }
  }
}

Log:

poc-localstack-1  | 2024-02-07T21:45:01.136 ERROR --- [d-102 (eval)] l.s.s.a.c.eval_component   : Exception=TypeError, Details=["cannot pickle '_io.BufferedReader' object"] at '(ResultPath| {'result_path_src': '$'}'
poc-localstack-1  | 2024-02-07T21:45:01.137  WARN --- [d-102 (eval)] l.s.s.a.c.s.s.execute_stat : State Task encountered an unhandled exception that lead to a State.Runtime error.
poc-localstack-1  | 2024-02-07T21:45:01.139 ERROR --- [d-102 (eval)] l.s.s.a.c.eval_component   : Exception=FailureEventException, Error=States.Runtime, Details={"taskFailedEventDetails": {"error": "States.Runtime", "cause": "cannot pickle '_io.BufferedReader' object"}} at '(StateTaskServiceAwsSdk| {'comment': None, 'input_path': (InputPath| {'input_path_src': '$'}, 'output_path': (OutputPath| {'output_path': '$'}, 'state_entered_event_type': 'TaskStateEntered', 'state_exited_event_type': 'TaskStateExited', 'result_path': (ResultPath| {'result_path_src': '$'}, 'result_selector': None, 'retry': None, 'catch': None, 'timeout': (TimeoutSeconds| {'timeout_seconds': 99999999, 'is_default': None}, 'heartbeat': None, 'parameters': (Parameters| {'payload_tmpl': (PayloadTmpl| {'payload_bindings': [(PayloadBindingPath| {'field': 'Bucket', 'path': '$.detail.bucket.name'}, (PayloadBindingPath| {'field': 'Key', 'path': '$.detail.object.key'}]}}, 'name': 'GetObject', 'state_type': <StateType.Task: 16>, 'continue_with': <localstack.services.stepfunctions.asl.component.state.state_continue_with.ContinueWithEnd object at 0x7fe8d4fca310>, 'resource': (ServiceResource| {'_region': '', '_account': '', 'resource_arn': 'arn:aws:states:::aws-sdk:s3:getObject', 'partition': 'aws', 'service_name': 'aws-sdk', 'api_name': 's3', 'api_action': 'getObject', 'condition': None}}'

Expected Behavior

The file should be downloaded and outputted as a string in the "Body".

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

`docker-compose up` which calls a shell script that calls: `tflocal init`, `tflocal plan`, and `tflocal apply`

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

aws --endpoint-url=http://localhost:4566 s3 cp test1.xml s3://poc-file-drop/

Environment

- OS: wsl2 + Ubuntu 22.04.1 LTS
- LocalStack: 3.1.0

Anything else?

Thank you!

marc2982 avatar Feb 07 '24 22:02 marc2982

Running into the same issue:

2024-05-19T19:17:37.047 ERROR --- [ad-56 (eval)] l.s.s.a.c.eval_component   : Exception=FailureEventException, Error=States.Runtime, Details={"taskFailedEventDetails": {"error": "States.Runtime", "cause": "cannot pickle '_io.BufferedReader' object"}} at '(StateTaskServiceAwsSdk| {'comment': None, 'input_path': (InputPath| {'input_path_src': '$'}, 'output_path': (OutputPath| {'output_path': '$'}, 'state_entered_event_type': 'TaskStateEntered', 'state_exited_event_type': 'TaskStateExited', 'result_path': (ResultPath| {'result_path_src': '$'}, 'result_selector': None, 'retry': None, 'catch': None, 'timeout': (TimeoutSeconds| {'timeout_seconds': 99999999, 'is_default': None}, 'heartbeat': None, 'parameters': (Parameters| {'payload_tmpl': (PayloadTmpl| {'payload_bindings': [(PayloadBindingValue| {'field': 'Bucket', 'value': (PayloadValueStr| {'val': 'sample-bucket'}}, (PayloadBindingPath| {'field': 'Key', 'path': '$.s3Key'}]}}, 'name': 'FetchCSV', 'state_type': <StateType.Task: 16>, 'continue_with': <localstack.services.stepfunctions.asl.component.state.state_continue_with.ContinueWithEnd object at 0xffff44a45b90>, 'resource': (ServiceResource| {'_region': '', '_account': '', 'resource_arn': 'arn:aws:states:::aws-sdk:s3:getObject', 'partition': 'aws', 'service_name': 'aws-sdk', 'api_name': 's3', 'api_action': 'getObject', 'condition': None}}'

This works locally though, and I get the file back:

awslocal s3 cp s3://sample-bucket/cea9e5e5-d2dc-4059-9717-19edf11bc375.csv .

anoopsin avatar May 19 '24 19:05 anoopsin

Hello 👋! It looks like this issue hasn’t been active in longer than five months. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

localstack-bot avatar Oct 16 '24 20:10 localstack-bot