You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "elad-galili-ka (via GitHub)" <gi...@apache.org> on 2023/06/28 09:13:26 UTC
[GitHub] [airflow] elad-galili-ka opened a new issue, #32227: LambdaInvokeFunctionOperator expects wrong type for payload arg
elad-galili-ka opened a new issue, #32227:
URL: https://github.com/apache/airflow/issues/32227
### Apache Airflow version
2.6.2
### What happened
I instantiate LambdaInvokeFunctionOperator in my DAG.
I want to call the lambda function with some payload. After following code example from official documentation, I created a dict, and passed its json string version to the operator:
```
d = {'key': 'value'}
invoke_lambda_task = LambdaInvokeFunctionOperator(..., payload=json.dumps(d))
```
When I executed the DAG, this task failed. I got the following error message:
```
Invalid type for parameter Payload, value: {'key': 'value'}, type: <class 'dict'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object
```
Then I went to official boto3 documentation, and found out that indeed, the payload parameter type is `bytes` or file. See https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda/client/invoke.html
### What you think should happen instead
To preserve backward compatibility, The API should encode payload argument if it is str, but also accept bytes or file, in which case it will be passed-through as is.
### How to reproduce
1. Create lambda function in AWS
2. Create a simple DAG with LambdaInvokeFunctionOperator
3. pass str value in the payload parameter; use json.dumps() with a simple dict, as lambda expects json payload
4. Run the DAG; the task is expected to fail
### Operating System
ubuntu
### Versions of Apache Airflow Providers
apache-airflow-providers-amazon==7.3.0
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #32227: LambdaInvokeFunctionOperator expects wrong type for payload arg
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #32227:
URL: https://github.com/apache/airflow/issues/32227#issuecomment-1611053914
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal closed issue #32227: LambdaInvokeFunctionOperator expects wrong type for payload arg
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal closed issue #32227: LambdaInvokeFunctionOperator expects wrong type for payload arg
URL: https://github.com/apache/airflow/issues/32227
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal commented on issue #32227: LambdaInvokeFunctionOperator expects wrong type for payload arg
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on issue #32227:
URL: https://github.com/apache/airflow/issues/32227#issuecomment-1611128737
Feel free to raise PR. Assigned the issue to you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org