1cadumagalhaes commented on code in PR #51097:
URL: https://github.com/apache/airflow/pull/51097#discussion_r2109688011
##########
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:
Hi @uranusjr
Some of these arent needed, for what I've tested. But the discord response
doesnt say whats wrong:
```
400 - {"embeds": ["0"]}
```
This happens when passing a invalid url or color. The other ones I can
remove with no problem.
--
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]