Repository: oppia/oppia

Issue:
Subscribe button not working on Oppia homepage
### Describe the bug

it doesn't actually do/say/confirm anything when you subscribe and i don't seem to be getting an email. Is it linked to mailchimp? If not, it needs to be to activate the welcome email.

### URL of the page where the issue is observed.

oppia.org

### Steps To Reproduce

go to home page - filled in my email in the subscribe button at the bottom of the page, click subscribe.

### Expected Behavior

I expect some kind of confirmation - perhaps replacing the field and/or button with a "thank you for subscribing!" and then receiving an email

### Screenshots/Videos

_No response_

### What device are you using?

Desktop

### Operating System

Windows

### What browsers are you seeing the problem on?

Chrome

### Browser version

_No response_

### Additional context

_No response_

### Tips for developers

Before addressing the bug, please identify which PR caused the issue (you can follow the steps [here](https://github.com/oppia/oppia/wiki/How-to-find-the-commit-which-introduced-a-bug)). If you identify the PR, comment on the issue with a link to it. If not, mention the commit hash of the oldest commit you saw the bug on (and the month and year it was made in).

Also, if this is your first issue, please make sure to follow https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue and https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up before claiming it. Thanks!

Subscribe button not working on Oppia homepage
### Describe the bug

it doesn't actually do/say/confirm anything when you subscribe and i don't seem to be getting an email. Is it linked to mailchimp? If not, it needs to be to activate the welcome email.

### URL of the page where the issue is observed.

oppia.org

### Steps To Reproduce

go to home page - filled in my email in the subscribe button at the bottom of the page, click subscribe.

### Expected Behavior

I expect some kind of confirmation - perhaps replacing the field and/or button with a "thank you for subscribing!" and then receiving an email

### Screenshots/Videos

_No response_

### What device are you using?

Desktop

### Operating System

Windows

### What browsers are you seeing the problem on?

Chrome

### Browser version

_No response_

### Additional context

_No response_

### Tips for developers

Before addressing the bug, please identify which PR caused the issue (you can follow the steps [here](https://github.com/oppia/oppia/wiki/How-to-find-the-commit-which-introduced-a-bug)). If you identify the PR, comment on the issue with a link to it. If not, mention the commit hash of the oldest commit you saw the bug on (and the month and year it was made in).

Also, if this is your first issue, please make sure to follow https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue and https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up before claiming it. Thanks!



Discussion:
Update: the issue here is that the backend handler that gets called when the Subscribe button is clicked requires a name to be specified as part of the backend validation schema (see [wiki](https://github.com/oppia/oppia/wiki/Schemas#validating-controller-arguments)). In this case, no name is specified, so the backend is erroring. 

We need to:

- Write a backend test for that handler that passes in `null` as a name, and ensures that the response is handled correctly; that test should fail.
- Make the backend handler validation treat the name as optional (i.e. it should be OK to pass in null for it) -- the previously-written test should then pass.

If you'd like to pick up this issue, please specify the exact name of the backend handler you are modifying and show screenshots of the changes you would make. Thanks!
P.S. This is a high-priority issue. Once it gets fixed, we should arrange a hotfix so that it goes live on the site ASAP. /cc @kevintab95 @chris7716 for info
Update: the issue here is that the backend handler that gets called when the Subscribe button is clicked requires a name to be specified as part of the backend validation schema (see [wiki](https://github.com/oppia/oppia/wiki/Schemas#validating-controller-arguments)). In this case, no name is specified, so the backend is erroring. 

We need to:

- Write a backend test for that handler that passes in `null` as a name, and ensures that the response is handled correctly; that test should fail.
- Make the backend handler validation treat the name as optional (i.e. it should be OK to pass in null for it) -- the previously-written test should then pass.

If you'd like to pick up this issue, please specify the exact name of the backend handler you are modifying and show screenshots of the changes you would make. Thanks!
P.S. This is a high-priority issue. Once it gets fixed, we should arrange a hotfix so that it goes live on the site ASAP. /cc @kevintab95 @chris7716 for info

Resolving patch:
diff --git a/core/controllers/profile.py b/core/controllers/profile.py
--- a/core/controllers/profile.py
+++ b/core/controllers/profile.py
@@ -233,7 +233,8 @@ class MailingListSubscriptionHandler(
                     'validators': [{
                         'id': 'is_nonempty'
                     }]
-                }
+                },
+                'default_value': None
             },
             'tag': {
                 'schema': {
diff --git a/core/domain/user_services.py b/core/domain/user_services.py
--- a/core/domain/user_services.py
+++ b/core/domain/user_services.py
@@ -41,7 +41,7 @@
 
 from typing import (
     Dict, Final, List, Literal, Optional, Sequence, TypedDict,
-    Union, overload)
+    overload)
 
 MYPY = False
 if MYPY: # pragma: no cover
@@ -1594,7 +1594,7 @@ def record_user_created_an_exploration(user_id: str) -> None:
 def add_user_to_mailing_list(
     email: str,
     tag: str,
-    name: Union[str, None]=None
+    name: Optional[str]=None
 ) -> bool:
     """Adds user to the bulk email provider with the relevant tag and required
     merge fields.


Test patch:
diff --git a/core/controllers/profile_test.py b/core/controllers/profile_test.py
--- a/core/controllers/profile_test.py
+++ b/core/controllers/profile_test.py
@@ -1095,6 +1095,14 @@ def test_put_function(self) -> None:
                 }, csrf_token=csrf_token)
             self.assertEqual(json_response, {'status': True})
 
+            # Name parameter should be optional.
+            json_response = self.put_json(
+                '/mailinglistsubscriptionhandler', {
+                    'email': 'email2@example.com',
+                    'tag': 'Web',
+                }, csrf_token=csrf_token)
+            self.assertEqual(json_response, {'status': True})
+
         self.logout()
 
     def test_email_provider_error(self) -> None: