vincbeck commented on code in PR #32259:
URL: https://github.com/apache/airflow/pull/32259#discussion_r1246758482


##########
tests/system/providers/amazon/aws/example_lambda.py:
##########
@@ -103,7 +103,7 @@ def delete_lambda(function_name: str):
     invoke_lambda_function = LambdaInvokeFunctionOperator(
         task_id="invoke_lambda_function",
         function_name=lambda_function_name,
-        payload=json.dumps({"SampleEvent": {"SampleData": {"Name": "XYZ", 
"DoB": "1993-01-01"}}}),
+        payload=json.dumps({"SampleEvent": {"SampleData": {"Name": "XYZ", 
"DoB": "1993-01-01"}}}).encode(),

Review Comment:
   I would leave it as str. The operator/hook takes care of the encoding



##########
airflow/providers/amazon/aws/operators/lambda_function.py:
##########
@@ -150,19 +150,23 @@ def __init__(
         qualifier: str | None = None,
         invocation_type: str | None = None,
         client_context: str | None = None,
-        payload: str | None = None,
+        payload: str | bytes | None = None,
         aws_conn_id: str = "aws_default",
         **kwargs,
     ):
         super().__init__(**kwargs)
         self.function_name = function_name
-        self.payload = payload
         self.log_type = log_type
         self.qualifier = qualifier
         self.invocation_type = invocation_type
         self.client_context = client_context
         self.aws_conn_id = aws_conn_id
 
+        if type(payload) == str:
+            payload = payload.encode()
+
+        self.payload = payload

Review Comment:
   I would do this in the hook to preserve backward compatibility



##########
airflow/providers/amazon/aws/hooks/lambda_function.py:
##########
@@ -48,7 +48,7 @@ def invoke_lambda(
         invocation_type: str | None = None,
         log_type: str | None = None,
         client_context: str | None = None,
-        payload: str | None = None,
+        payload: bytes | None = None,

Review Comment:
   This is breaking change. You cannot do that. That will break any user using 
the hook with `payload` as string



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to