Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: outgoing email account handlng #24656

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

ankush
Copy link
Member

@ankush ankush commented Feb 1, 2024

  1. Currently we give this weird error instead of just saying no outgoing email account is configured.
AttributeError: 'NoneType' object has no attribute 'get_smtp_server'
  File "frappe/email/queue.py", line 154, in flush
    email_queue.send()
  File "frappe/email/doctype/email_queue/email_queue.py", line 160, in send
    with SendMailContext(self, smtp_server_instance) as ctx:
  File "frappe/email/doctype/email_queue/email_queue.py", line 236, in __init__
    self.smtp_server: SMTPServer = smtp_server_instance or self.email_account_doc.get_smtp_server()
  1. These failures don't trigger email queue's retry code because this attempt doesn't get logged. Moved all code that can possibly fail from __init__ or __enter__ to context.

closes #24480

@ankush ankush requested review from a team and surajshetty3416 and removed request for a team February 1, 2024 05:38
@ankush ankush marked this pull request as draft February 1, 2024 05:39
Currently we give this weird error instead of just saying no outgoing email account is configured.

```
AttributeError: 'NoneType' object has no attribute 'get_smtp_server'
  File "frappe/email/queue.py", line 154, in flush
    email_queue.send()
  File "frappe/email/doctype/email_queue/email_queue.py", line 160, in send
    with SendMailContext(self, smtp_server_instance) as ctx:
  File "frappe/email/doctype/email_queue/email_queue.py", line 236, in __init__
    self.smtp_server: SMTPServer = smtp_server_instance or self.email_account_doc.get_smtp_server()
```
Currently if smtp server creation fails email queue is endlessly
retried. It should just fail if there's no outgoing account.
@ankush ankush marked this pull request as ready for review February 1, 2024 05:49
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0458544) 61.90% compared to head (dae99eb) 61.92%.
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24656      +/-   ##
===========================================
+ Coverage    61.90%   61.92%   +0.01%     
===========================================
  Files          786      786              
  Lines        75188    75168      -20     
  Branches      6430     6430              
===========================================
  Hits         46548    46548              
+ Misses       24892    24872      -20     
  Partials      3748     3748              
Flag Coverage Δ
server 70.98% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ankush ankush enabled auto-merge February 1, 2024 06:22
@ankush ankush merged commit bedf5ba into frappe:develop Feb 1, 2024
25 checks passed
@ankush ankush deleted the retry_contact branch February 1, 2024 06:22
@ankush ankush added the backport version-15-hotfix Backport the PR to v15 label Feb 1, 2024
ankush added a commit that referenced this pull request Feb 1, 2024
* fix: Bail if no SMTP acccount can be found

Currently we give this weird error instead of just saying no outgoing email account is configured.

```
AttributeError: 'NoneType' object has no attribute 'get_smtp_server'
  File "frappe/email/queue.py", line 154, in flush
    email_queue.send()
  File "frappe/email/doctype/email_queue/email_queue.py", line 160, in send
    with SendMailContext(self, smtp_server_instance) as ctx:
  File "frappe/email/doctype/email_queue/email_queue.py", line 236, in __init__
    self.smtp_server: SMTPServer = smtp_server_instance or self.email_account_doc.get_smtp_server()
```

(cherry picked from commit 78665d9)

* fix: Fetch SMTP server inside context

Currently if smtp server creation fails email queue is endlessly
retried. It should just fail if there's no outgoing account.

(cherry picked from commit dae99eb)

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
@ankush ankush added the backport version-14-hotfix backport to version 14 label Feb 1, 2024
ankush added a commit that referenced this pull request Feb 5, 2024
* fix: Bail if no SMTP acccount can be found

Currently we give this weird error instead of just saying no outgoing email account is configured.

```
AttributeError: 'NoneType' object has no attribute 'get_smtp_server'
  File "frappe/email/queue.py", line 154, in flush
    email_queue.send()
  File "frappe/email/doctype/email_queue/email_queue.py", line 160, in send
    with SendMailContext(self, smtp_server_instance) as ctx:
  File "frappe/email/doctype/email_queue/email_queue.py", line 236, in __init__
    self.smtp_server: SMTPServer = smtp_server_instance or self.email_account_doc.get_smtp_server()
```

(cherry picked from commit 78665d9)

* fix: Fetch SMTP server inside context

Currently if smtp server creation fails email queue is endlessly
retried. It should just fail if there's no outgoing account.

(cherry picked from commit dae99eb)

# Conflicts:
#	frappe/email/doctype/email_queue/email_queue.py

* chore: conflicts

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
frappe-pr-bot pushed a commit that referenced this pull request Feb 6, 2024
# [14.65.0](v14.64.0...v14.65.0) (2024-02-06)

### Bug Fixes

* Allow int fields to be unique ([#24750](#24750)) ([#24755](#24755)) ([7f19ea2](7f19ea2))
* Check if header/footer html exists before trying to extract ([c1dc4b9](c1dc4b9))
* Custom Script runs twice ([a70de37](a70de37))
* data import table UI fix ([d3d3354](d3d3354))
* do not allow to set if_owner & report perm together ([40a0065](40a0065))
* enable syntax highlighting for `PythonExpression` code fields ([#24669](#24669)) ([#24670](#24670)) ([666040c](666040c))
* Enqueue deletion of dynamic link after comitting ([#24674](#24674)) ([9eb9878](9eb9878))
* Extract header/footer html into `content` to simplify things ([2d11989](2d11989))
* **js:** Handle hidden virtual fields ([#24405](#24405)) ([#24691](#24691)) ([50c18ab](50c18ab))
* Make as_iterator work when there are no child queries ([#24748](#24748)) ([40d5741](40d5741))
* make rate_limiter respect multitenancy (backport [#24634](#24634)) ([#24635](#24635)) ([e49a5a0](e49a5a0))
* Missing `footer_html ` declaration ([d75dfef](d75dfef))
* outgoing email account handlng (backport [#24656](#24656)) ([#24685](#24685)) ([9ba3c9e](9ba3c9e))
* short circuit private files perm check ([b2d105a](b2d105a))
* show folders in Google Drive Picker ([e5f1137](e5f1137)), closes [#23096](#23096)
* Show proper error message for prepared report failure ([#24733](#24733)) ([#24736](#24736)) ([379d893](379d893))
* Skip fulltext indexes during sync ([#24728](#24728)) ([#24732](#24732)) ([1a8e049](1a8e049))
* Translate Letterhead information string ([00c4b77](00c4b77))
* typeerror in onboarding_tours.js ([7cca45f](7cca45f))
* Use `TEXT` type for Webhook URLs to support large URLs (backport [#24761](#24761)) ([#24762](#24762)) ([e5ff86a](e5ff86a))
* virtual fields are never writable ([#24693](#24693)) ([#24695](#24695)) ([22e26f6](22e26f6))

### Features

* Dynamic headers/footers & fix disappearing header ([343ac16](343ac16))
* Include letterhead scripts in print (html) ([5321e5d](5321e5d))

### Performance Improvements

* optional faster perm check for files (backport [#24624](#24624)) ([#24630](#24630)) ([6778fe2](6778fe2))
frappe-pr-bot pushed a commit that referenced this pull request Feb 6, 2024
# [15.13.0](v15.12.0...v15.13.0) (2024-02-06)

### Bug Fixes

* Allow int fields to be unique ([#24750](#24750)) ([#24756](#24756)) ([6c5ea2f](6c5ea2f))
* Avoid enqueueing during install ([#24679](#24679)) ([#24682](#24682)) ([7825a72](7825a72))
* Check if header/footer html exists before trying to extract ([03fc5b1](03fc5b1))
* check is_translatable link ([#24739](#24739)) ([#24747](#24747)) ([e21e2ca](e21e2ca))
* clear sitemap cache periodically ([#24676](#24676)) ([282e0e6](282e0e6))
* console import progress off-by-one ([#24777](#24777)) ([#24787](#24787)) ([e6ad6e8](e6ad6e8))
* Custom Script runs twice ([5d7d7f7](5d7d7f7))
* Dashboard view realtime error ([#24698](#24698)) ([#24699](#24699)) ([a2a766b](a2a766b))
* data import table UI fix ([064aca2](064aca2))
* date format & pre commit test ([9726c46](9726c46))
* depends on ([9777fe3](9777fe3))
* description ([fe7ed4b](fe7ed4b))
* Disappearing letterhead header in pdf ([e932958](e932958))
* do not allow to set if_owner & report perm together ([290b7e8](290b7e8))
* don't notify links if not public ([019c223](019c223))
* enable syntax highlighting for `PythonExpression` code fields ([#24669](#24669)) ([#24671](#24671)) ([4bbfaa7](4bbfaa7))
* Enqueue deletion of dynamic link after comitting ([#24675](#24675)) ([9fbe981](9fbe981))
* Extract header/footer html into `content` to simplify things ([64102a7](64102a7))
* formatting ([05a6ad8](05a6ad8))
* formatting ([5ba9be8](5ba9be8))
* hide number counter for new document view shortcut ([bb46d23](bb46d23))
* **js:** Handle hidden virtual fields ([#24405](#24405)) ([#24692](#24692)) ([ea82c81](ea82c81))
* **login:** Escape translated strings ([#24431](#24431)) ([#24701](#24701)) ([73c66ce](73c66ce))
* lower default retention periods ([#24697](#24697)) ([#24705](#24705)) ([a155f9e](a155f9e))
* make rate_limiter respect multitenancy ([#24634](#24634)) ([d25bfd9](d25bfd9))
* Make sure sitemap respects robot_txt ([10b583b](10b583b))
* never show virtual fields in list view (backport [#24666](#24666)) ([#24668](#24668)) ([45e2683](45e2683))
* no of rows displayed based on report type ([db4d36f](db4d36f))
* outgoing email account handlng (backport [#24656](#24656)) ([#24657](#24657)) ([4a59a01](4a59a01))
* redirect and open new doctype dialog if route to /doctype/new ([fec821a](fec821a))
* Retry contact update if it fails due to conflict ([#24654](#24654)) ([#24655](#24655)) ([22aa5d3](22aa5d3))
* Set default for search result limit if empty ([#24713](#24713)) ([#24715](#24715)) ([474feb8](474feb8))
* short circuit private files perm check ([e6d7ffe](e6d7ffe))
* show folders in Google Drive Picker ([0d99ef8](0d99ef8)), closes [#23096](#23096)
* Show proper error message for prepared report failure ([#24733](#24733)) ([#24737](#24737)) ([99676af](99676af))
* Skip fulltext indexes during sync ([#24728](#24728)) ([#24734](#24734)) ([8e078f3](8e078f3))
* suggestion ([63764a9](63764a9))
* title link check ([#24731](#24731)) ([#24735](#24735)) ([5c006cd](5c006cd))
* Translate Letterhead information string ([8dfa972](8dfa972))
* typeerror in onboarding_tours.js ([5ae79be](5ae79be))
* Use `TEXT` type for Webhook URLs to support large URLs ([#24763](#24763)) ([f31a3ce](f31a3ce))
* **UX:** improve server script message ([#24770](#24770)) ([5d88275](5d88275))
* virtual fields are never writable ([#24693](#24693)) ([#24696](#24696)) ([d020771](d020771))
* **website:** Handle virtual DocTypes webview routing ([#24445](#24445)) ([#24743](#24743)) ([bed66ca](bed66ca))

### Features

* allow extending site config with a hook ([ffed7bf](ffed7bf))
* Letterhead scripts ([9b296cd](9b296cd))
* **recorder:** profiling and granular recording (backport [#24683](#24683)) ([#24742](#24742)) ([fd04617](fd04617))
* show doctype description on list title hover (backport [#24612](#24612)) ([#24769](#24769)) ([5a0e20b](5a0e20b))
* show doctype description on workspace link hover ([#24598](#24598)) ([#24789](#24789)) ([6107338](6107338))
* use_first_day_of_period ([1fcb105](1fcb105))

### Performance Improvements

* optional faster perm check for files ([3e4a344](3e4a344))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14 backport version-15-hotfix Backport the PR to v15
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Newsletter Email Queue Error
1 participant