hankehly commented on code in PR #30981:
URL: https://github.com/apache/airflow/pull/30981#discussion_r1181364357
##########
airflow/providers/google/cloud/hooks/pubsub.py:
##########
@@ -144,25 +146,27 @@ def _validate_messages(messages) -> None:
try:
b64decode(message["data"])
warnings.warn(
+ "During message validation, the 'data' field was
successfully decoded as base64. "
"The base 64 encoded string as 'data' field has been
deprecated. "
- "You should pass bytestring (utf-8 encoded).",
+ "You should pass bytestring (utf-8 encoded). "
+ "If you did not pass base64 encoded string, you can
ignore this warning.",
DeprecationWarning,
stacklevel=4,
)
except ValueError:
pass
if not isinstance(message, dict):
- raise PubSubException("Wrong message type. Must be a
dictionary.")
+ raise PubSubException("Invalid message type. Must be a
dictionary.")
if "data" not in message and "attributes" not in message:
- raise PubSubException("Wrong message. Dictionary must contain
'data' or 'attributes'.")
- if "data" in message and not isinstance(message["data"], bytes):
- raise PubSubException("Wrong message. 'data' must be send as a
bytestring")
+ raise PubSubException("Invalid message. Dictionary must
contain 'data' or 'attributes'.")
+ if "data" in message and not isinstance(message["data"], (str,
bytes)):
+ raise PubSubException("Invalid message. 'data' must be type
string or bytes.")
Review Comment:
Updated the validation condition to allow for string-type message data.
--
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]