uranusjr commented on code in PR #51097:
URL: https://github.com/apache/airflow/pull/51097#discussion_r2108069634
##########
providers/discord/src/airflow/providers/discord/hooks/discord_webhook.py:
##########
@@ -119,6 +133,26 @@ def _get_webhook_endpoint(self, http_conn_id: str | None,
webhook_endpoint: str
return endpoint
+ def _validate_embeds(self, embeds: list[dict[str, Any]]) -> None:
+ """
+ Validate the structure of the embeds.
+
+ :param embeds: List of embed objects to validate
+ :raises AirflowException: If any embed object is invalid
+ """
+ for embed in embeds:
+ if not isinstance(embed, dict):
+ raise AirflowException("Each embed must be a dictionary.")
+ if "title" in embed and not isinstance(embed["title"], str):
+ raise AirflowException("Embed title must be a string.")
+ if "description" in embed and not isinstance(embed["description"],
str):
+ raise AirflowException("Embed description must be a string.")
+ if "url" in embed and not isinstance(embed["url"], str):
+ raise AirflowException("Embed URL must be a string.")
+ if "color" in embed and not isinstance(embed["color"], int):
+ raise AirflowException("Embed color must be an integer.")
+ # Add more validations as needed
Review Comment:
What happens if you just pass an invalid value to the discord? I feel we
shouldn’t need to do this babysitting work.
--
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]