hnajari opened a new issue, #39314:
URL: https://github.com/apache/airflow/issues/39314
### Apache Airflow version
Other Airflow 2 version (please specify below)
### If "Other Airflow 2 version" selected, which one?
2.7.3
### What happened?
I am using GCP composer with airflow 2.7.3, python 3.11.5 and sendgrid to
send emails on failure.
Using EmailOperator that's work well with conn_id = sendgrid_default
But the problem when task fail and option email_on_failure = True, airflow
throw error:
`
[2024-04-28, 08:00:30 UTC] {warnings.py:109} WARNING -
/opt/python3.11/lib/python3.11/site-packages/airflow/providers/sendgrid/utils/emailer.py:123:
AirflowProviderDeprecationWarning: Fetching Sendgrid credentials from
environment variables will be deprecated in a future release. Please set
credentials using a connection instead.
_post_sendgrid_mail(mail.get(), conn_id)
[2024-04-28, 08:00:31 UTC] {taskinstance.py:2009} ERROR - Failed to send
email to: ['[email protected]']
Traceback (most recent call last):
File
"/opt/python3.11/lib/python3.11/site-packages/airflow/models/taskinstance.py",
line 2007, in handle_failure
self.email_alert(error, task)
File
"/opt/python3.11/lib/python3.11/site-packages/airflow/models/taskinstance.py",
line 2425, in email_alert
send_email(task.email, subject, html_content_err)
File
"/opt/python3.11/lib/python3.11/site-packages/airflow/utils/email.py", line 80,
in send_email
return backend(
^^^^^^^^
File
"/opt/python3.11/lib/python3.11/site-packages/airflow/providers/sendgrid/utils/emailer.py",
line 123, in send_email
_post_sendgrid_mail(mail.get(), conn_id)
File
"/opt/python3.11/lib/python3.11/site-packages/airflow/providers/sendgrid/utils/emailer.py",
line 142, in _post_sendgrid_mail
response = sendgrid_client.client.mail.send.post(request_body=mail_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/opt/python3.11/lib/python3.11/site-packages/python_http_client/client.py",
line 277, in http_request
self._make_request(opener, request, timeout=timeout)
File
"/opt/python3.11/lib/python3.11/site-packages/python_http_client/client.py",
line 184, in _make_request
raise exc
python_http_client.exceptions.UnauthorizedError: HTTP Error 401: Unauthorized
`
Can you help me ? Thank you
### What you think should happen instead?
receive failure email with error details
### How to reproduce
In dags, with email_on_failure = True,
when task fail, we should receive a failure error.
### Operating System
composer
### Versions of Apache Airflow Providers
_No response_
### Deployment
Google Cloud Composer
### Deployment details
cloud composer 2.6.6 with airflow 2.7.3 and python 3.11.5
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]