prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  User.DoesNotExist: User matching query does not exist.
  Sentry Issue: [EDUCATION-BACKEND-23](https://sentry.io/organizations/f213/issues/2200858697/?referrer=github_integration)
  
  ```
  User.DoesNotExist: User matching query does not exist.
    File "celery/app/autoretry.py", line 34, in run
      return task._orig_run(*args, **kwargs)
    File "app/tasks.py", line 77, in subscribe_to_mailchimp
      user=apps.get_model('users.User').objects.get(pk=user_id),
    File "django/db/models/manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "django/db/models/query.py", line 435, in get
      raise self.model.DoesNotExist(
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/app/tasks.py`
  Content:
  ```
  1 from typing import List, Union
  2 
  3 from anymail.exceptions import AnymailRequestsAPIError
  4 from django.apps import apps
  5 from django.conf import settings
  6 from requests.exceptions import RequestException
  7 
  8 from app.celery import celery
  9 from app.integrations import tg
  10 from app.integrations.clickmeeting import ClickMeetingClient, ClickMeetingHTTPException
  11 from app.integrations.mailchimp import AppMailchimp, MailchimpException
  12 from app.integrations.zoomus import ZoomusClient, ZoomusHTTPException
  13 from app.mail.owl import TemplOwl
  14 
  15 
  16 @celery.task(
  17     autoretry_for=[AnymailRequestsAPIError],
  18     retry_kwargs={
  19         'max_retries': 10,
  20         'countdown': 5,
  21     },
  22 )
  23 def send_mail(to: Union[List, str], template_id, subject: str = '', ctx: dict = None, disable_antispam=False):
  24     TemplOwl(
  25         to=to,
  26         template_id=template_id,
  27         subject=subject,
  28         ctx=ctx,
  29         disable_antispam=disable_antispam,
  30     ).send()
  31 
  32 
  33 @celery.task(
  34     autoretry_for=[RequestException, ClickMeetingHTTPException],
  35     retry_kwargs={
  36         'max_retries': 10,
  37         'countdown': 5,
  38     },
  39 )
  40 def invite_to_clickmeeting(room_url: str, email: str):
  41     client = ClickMeetingClient()
  42     client.invite(room_url, email)
  43 
  44 
  45 @celery.task(
  46     autoretry_for=[RequestException, ZoomusHTTPException],
  47     retry_kwargs={
  48         'max_retries': 10,
  49         'countdown': 5,
  50     },
  51 )
  52 def invite_to_zoomus(webinar_id: str, user_id: int):
  53     user = apps.get_model('users.User').objects.get(pk=user_id)
  54 
  55     client = ZoomusClient()
  56     client.invite(webinar_id, user)
  57 
  58 
  59 @celery.task(
  60     autoretry_for=[RequestException, MailchimpException],
  61     retry_kwargs={
  62         'max_retries': 10,
  63         'countdown': 5,
  64     },
  65 )
  66 def subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):
  67     if list_id is None:
  68         list_id = settings.MAILCHIMP_CONTACT_LIST_ID
  69 
  70     if not list_id:
  71         return
  72 
  73     mailchimp = AppMailchimp()
  74 
  75     mailchimp.subscribe_django_user(
  76         list_id=list_id,
  77         user=apps.get_model('users.User').objects.get(pk=user_id),
  78         tags=tags,
  79     )
  80 
  81 
  82 @celery.task
  83 def send_happiness_message(text):
  84     tg.send_happiness_message(text)
  85
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/app/tasks.py b/src/app/tasks.py
  --- a/src/app/tasks.py
  +++ b/src/app/tasks.py
  @@ -3,6 +3,7 @@
   from anymail.exceptions import AnymailRequestsAPIError
   from django.apps import apps
   from django.conf import settings
  +from django.core.exceptions import ObjectDoesNotExist
   from requests.exceptions import RequestException
   
   from app.celery import celery
  @@ -57,11 +58,12 @@
   
   
   @celery.task(
  -    autoretry_for=[RequestException, MailchimpException],
  +    autoretry_for=[RequestException, MailchimpException, ObjectDoesNotExist],
       retry_kwargs={
           'max_retries': 10,
           'countdown': 5,
       },
  +    rate_limit='1/s',
   )
   def subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):
       if list_id is None:
  
verification_info: {"golden_diff": "diff --git a/src/app/tasks.py b/src/app/tasks.py\n--- a/src/app/tasks.py\n+++ b/src/app/tasks.py\n@@ -3,6 +3,7 @@\n from anymail.exceptions import AnymailRequestsAPIError\n from django.apps import apps\n from django.conf import settings\n+from django.core.exceptions import ObjectDoesNotExist\n from requests.exceptions import RequestException\n \n from app.celery import celery\n@@ -57,11 +58,12 @@\n \n \n @celery.task(\n-    autoretry_for=[RequestException, MailchimpException],\n+    autoretry_for=[RequestException, MailchimpException, ObjectDoesNotExist],\n     retry_kwargs={\n         'max_retries': 10,\n         'countdown': 5,\n     },\n+    rate_limit='1/s',\n )\n def subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):\n     if list_id is None:\n", "issue": "User.DoesNotExist: User matching query does not exist.\nSentry Issue: [EDUCATION-BACKEND-23](https://sentry.io/organizations/f213/issues/2200858697/?referrer=github_integration)\n\n```\nUser.DoesNotExist: User matching query does not exist.\n  File \"celery/app/autoretry.py\", line 34, in run\n    return task._orig_run(*args, **kwargs)\n  File \"app/tasks.py\", line 77, in subscribe_to_mailchimp\n    user=apps.get_model('users.User').objects.get(pk=user_id),\n  File \"django/db/models/manager.py\", line 85, in manager_method\n    return getattr(self.get_queryset(), name)(*args, **kwargs)\n  File \"django/db/models/query.py\", line 435, in get\n    raise self.model.DoesNotExist(\n```\n", "before_files": [{"content": "from typing import List, Union\n\nfrom anymail.exceptions import AnymailRequestsAPIError\nfrom django.apps import apps\nfrom django.conf import settings\nfrom requests.exceptions import RequestException\n\nfrom app.celery import celery\nfrom app.integrations import tg\nfrom app.integrations.clickmeeting import ClickMeetingClient, ClickMeetingHTTPException\nfrom app.integrations.mailchimp import AppMailchimp, MailchimpException\nfrom app.integrations.zoomus import ZoomusClient, ZoomusHTTPException\nfrom app.mail.owl import TemplOwl\n\n\n@celery.task(\n    autoretry_for=[AnymailRequestsAPIError],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef send_mail(to: Union[List, str], template_id, subject: str = '', ctx: dict = None, disable_antispam=False):\n    TemplOwl(\n        to=to,\n        template_id=template_id,\n        subject=subject,\n        ctx=ctx,\n        disable_antispam=disable_antispam,\n    ).send()\n\n\n@celery.task(\n    autoretry_for=[RequestException, ClickMeetingHTTPException],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef invite_to_clickmeeting(room_url: str, email: str):\n    client = ClickMeetingClient()\n    client.invite(room_url, email)\n\n\n@celery.task(\n    autoretry_for=[RequestException, ZoomusHTTPException],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef invite_to_zoomus(webinar_id: str, user_id: int):\n    user = apps.get_model('users.User').objects.get(pk=user_id)\n\n    client = ZoomusClient()\n    client.invite(webinar_id, user)\n\n\n@celery.task(\n    autoretry_for=[RequestException, MailchimpException],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):\n    if list_id is None:\n        list_id = settings.MAILCHIMP_CONTACT_LIST_ID\n\n    if not list_id:\n        return\n\n    mailchimp = AppMailchimp()\n\n    mailchimp.subscribe_django_user(\n        list_id=list_id,\n        user=apps.get_model('users.User').objects.get(pk=user_id),\n        tags=tags,\n    )\n\n\n@celery.task\ndef send_happiness_message(text):\n    tg.send_happiness_message(text)\n", "path": "src/app/tasks.py"}], "after_files": [{"content": "from typing import List, Union\n\nfrom anymail.exceptions import AnymailRequestsAPIError\nfrom django.apps import apps\nfrom django.conf import settings\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom requests.exceptions import RequestException\n\nfrom app.celery import celery\nfrom app.integrations import tg\nfrom app.integrations.clickmeeting import ClickMeetingClient, ClickMeetingHTTPException\nfrom app.integrations.mailchimp import AppMailchimp, MailchimpException\nfrom app.integrations.zoomus import ZoomusClient, ZoomusHTTPException\nfrom app.mail.owl import TemplOwl\n\n\n@celery.task(\n    autoretry_for=[AnymailRequestsAPIError],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef send_mail(to: Union[List, str], template_id, subject: str = '', ctx: dict = None, disable_antispam=False):\n    TemplOwl(\n        to=to,\n        template_id=template_id,\n        subject=subject,\n        ctx=ctx,\n        disable_antispam=disable_antispam,\n    ).send()\n\n\n@celery.task(\n    autoretry_for=[RequestException, ClickMeetingHTTPException],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef invite_to_clickmeeting(room_url: str, email: str):\n    client = ClickMeetingClient()\n    client.invite(room_url, email)\n\n\n@celery.task(\n    autoretry_for=[RequestException, ZoomusHTTPException],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n)\ndef invite_to_zoomus(webinar_id: str, user_id: int):\n    user = apps.get_model('users.User').objects.get(pk=user_id)\n\n    client = ZoomusClient()\n    client.invite(webinar_id, user)\n\n\n@celery.task(\n    autoretry_for=[RequestException, MailchimpException, ObjectDoesNotExist],\n    retry_kwargs={\n        'max_retries': 10,\n        'countdown': 5,\n    },\n    rate_limit='1/s',\n)\ndef subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):\n    if list_id is None:\n        list_id = settings.MAILCHIMP_CONTACT_LIST_ID\n\n    if not list_id:\n        return\n\n    mailchimp = AppMailchimp()\n\n    mailchimp.subscribe_django_user(\n        list_id=list_id,\n        user=apps.get_model('users.User').objects.get(pk=user_id),\n        tags=tags,\n    )\n\n\n@celery.task\ndef send_happiness_message(text):\n    tg.send_happiness_message(text)\n", "path": "src/app/tasks.py"}]}