internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mdn/kuma

Issue:
Our flake8 tests suddenly failed
**Summary**
Builds from `master` currently fail in Python linting. 
It's because the version of [flake8 used in TravisCI](https://github.com/mdn/kuma/blob/59afefbe55ca8456203baa96ba421f1fa3b63ede/.travis.yml#L17-L18) don't match what we have in our pyproject.toml. 
Today a new release of flake8 came out that broke our master. [Example](https://travis-ci.com/github/mdn/kuma/jobs/332498567)



Discussion:

Resolving patch:
diff --git a/kuma/search/views.py b/kuma/search/views.py
--- a/kuma/search/views.py
+++ b/kuma/search/views.py
@@ -11,6 +11,7 @@
 
 from .search import SearchView
 
+
 # Since the search endpoint accepts user input (via query parameters) and its
 # response is compressed, use rate limiting to mitigate the BREACH attack
 # (see http://breachattack.com/). It still needs to allow a user to click
diff --git a/kuma/users/models.py b/kuma/users/models.py
--- a/kuma/users/models.py
+++ b/kuma/users/models.py
@@ -199,7 +199,7 @@ def get_recovery_url(self):
 
     def set_next_subscriber_number_and_save(self):
         assert not self.subscriber_number, "already set"
-        lock_key = f"set_next_subscriber_number_and_save"
+        lock_key = "set_next_subscriber_number_and_save"
         # By locking "globally", we get to be certain that our query to get
         # the current highest `subscriber_number`, gets done alone.
         with cache.lock(lock_key):


Test patch:
diff --git a/kuma/authkeys/tests/test_views.py b/kuma/authkeys/tests/test_views.py
--- a/kuma/authkeys/tests/test_views.py
+++ b/kuma/authkeys/tests/test_views.py
@@ -110,8 +110,8 @@ def test_key_history(self):
             log_lines.append(("ping", self.user2, "Number #%s" % i))
 
         # Record the log lines for this key
-        for l in log_lines:
-            self.key1.log(*l)
+        for log_line in log_lines:
+            self.key1.log(*log_line)
 
         # Reverse the lines for comparison.
         log_lines.reverse()
diff --git a/kuma/wiki/tests/test_ssr.py b/kuma/wiki/tests/test_ssr.py
--- a/kuma/wiki/tests/test_ssr.py
+++ b/kuma/wiki/tests/test_ssr.py
@@ -59,16 +59,10 @@ def test_server_side_render(
     output = ssr.render_react("SPA", locale, path, document_data)
 
     # Make sure the output is as expected
-    data = {
-        "locale": locale,
-        "url": path,
-        "stringCatalog": localization_data["catalog"],
-        "documentData": document_data,
-    }
     expect = (
-        '<div id="react-container" data-component-name="{}">{}</div>\n'
+        f'<div id="react-container" data-component-name="SPA">{mock_html}</div>\n'
         "<script>window._react_data = JSON.parse(STUFF);</script>\n"
-    ).format("SPA", mock_html, json.dumps(data))
+    )
     assert output == expect
Repository: mdn/kuma

Issue:
TypeError on sendinblue
https://sentry.prod.mozaws.net/operations/mdn-prod/issues/8473154/?referrer=github_plugin

```
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
  File "celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "newrelic/hooks/application_celery.py", line 85, in wrapper
    return wrapped(*args, **kwargs)
  File "celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
  File "kuma/users/newsletter/tasks.py", line 29, in create_or_update_contact
    "listIds": [int(settings.SENDINBLUE_LIST_ID)],

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
```


Discussion:
@Gregoor I think you and @ryan need to work on synchronizing the deployment and the environment variables. 

Resolving patch:
diff --git a/kuma/settings/pytest.py b/kuma/settings/pytest.py
--- a/kuma/settings/pytest.py
+++ b/kuma/settings/pytest.py
@@ -102,3 +102,6 @@
 # our tests to not deviate when the actual number changes since that number
 # change shouldn't affect the tests.
 CONTRIBUTION_AMOUNT_USD = 4.99
+
+SENDINBLUE_API_KEY = "testing"
+SENDINBLUE_LIST_ID = 7327
diff --git a/kuma/users/newsletter/apps.py b/kuma/users/newsletter/apps.py
--- a/kuma/users/newsletter/apps.py
+++ b/kuma/users/newsletter/apps.py
@@ -1,4 +1,5 @@
 from django.apps import AppConfig
+from django.conf import settings
 from django.core.checks import register
 from django.utils.translation import gettext_lazy as _
 
@@ -13,6 +14,9 @@ class UserNewsletterConfig(AppConfig):
     verbose_name = _("UserNewsletter")
 
     def ready(self):
+        if not settings.SENDINBLUE_API_KEY:
+            return
+
         # Connect signal handlers
         from . import signal_handlers  # noqa
 


Test patch:
Repository: mdn/kuma

Issue:
T - Remove all non essential URLs from robots.txt
**Summary**
In the past we have added pages we didn't want to be indexed to robots.txt, but that means that Google can't crawl them to see that we don't want those pages to be indexed. We should only have pages in robots.txt that we don't want a robot to crawl (possibly due to performance issues).


**Steps To Reproduce (STR)**
1. Go to Search Console
2. go to Coverage > Valid with Warnings > Indexed, though blocked by robots.txt
3. Alternatively: https://developer.mozilla.org/robots.txt


**Actual behavior**
Google has a link to https://developer.mozilla.org/users/google/login/?next=/en-US/docs/MDN/About/Promote (for example), but that URL is blocked in robots.txt, so it can't follow the link to see that it redirects to a sign in page.


**Expected behavior**
Disallow: /*users/ should be removed from robots.txt so Google crawler can follow those urls.


**Additional context**
The reason to do this is so we can see actually problematic content show up in our search console reports, instead of this noise. Search console only shows up to 1000 pages as problematic, but there are currently more than 10k warnings, so we might be missing large issues.



Discussion:

Resolving patch:
diff --git a/kuma/landing/views.py b/kuma/landing/views.py
--- a/kuma/landing/views.py
+++ b/kuma/landing/views.py
@@ -69,7 +69,6 @@ def promote_buttons(request):
 Disallow: /*/files/
 Disallow: /media
 Disallow: /*profiles*/edit
-Disallow: /*users/
 """ + "\n".join(
     "Disallow: /{locale}/search".format(locale=locale)
     for locale in settings.ENABLED_LOCALES


Test patch:
Repository: mdn/kuma

Issue:
Django User admin not working related to stripe_customer_id
**Summary**
<img width="1450" alt="Screen Shot 2020-05-20 at 1 01 52 PM" src="https://user-images.githubusercontent.com/26739/82475221-28e5a080-9a9a-11ea-948f-be97bf2c15d6.png">

There *exists* a user with that username. 
The user is there. I can manually type in the URL http://localhost.org:8000/admin/users/user/1311/change/ and it works. 

It's related to `IsStripeCustomer` in `kuma/users/admin.py`.

**Steps To Reproduce (STR)**

1. Have a user with and without a `stripe_customer_id`
2. Go to http://localhost.org:8000/admin/users/user/
3. Is the user appearing?


**Actual behavior**
_What actually happened?_


**Expected behavior**
_What did you expect to happen?_


**Additional context**
Pretty sure it's the `IsStripeCustomer` thing that's filtering on the empty string even if you didn't filter on it. 


Discussion:
I suspect that in here https://github.com/mdn/kuma/blob/f9206d32e598d3661af90bf33b1dd41b9d8aad5b/kuma/users/admin.py#L31-L35 we need to look at `self.value()` more closely. 
@atopal I think we'll probably turn this one into a P1 and have a resolution before we launch Stripe/Subscriptions but I think the Django User admin is busted at the moment. Users are simply not showing up. I think you work around it by filtering on "Yes" and "No" on the "By is Stripe Customer" filter. 
Yeah, would be nice, but not urgent. I don't really have a use case for this for now. Let me know if you do.

Resolving patch:
diff --git a/kuma/users/admin.py b/kuma/users/admin.py
--- a/kuma/users/admin.py
+++ b/kuma/users/admin.py
@@ -24,15 +24,18 @@ class IsStripeCustomer(admin.SimpleListFilter):
 
     def lookups(self, request, model_admin):
         return (
-            (True, "Yes"),
-            (False, "No"),
+            ("yes", "Yes"),
+            ("no", "No"),
         )
 
     def queryset(self, request, queryset):
-        if self.value():
+        value = self.value()
+        if value == "yes":
             return queryset.exclude(stripe_customer_id="")
-        else:
+        elif value == "no":
             return queryset.filter(stripe_customer_id="")
+        else:
+            return queryset
 
 
 @admin.register(User)


Test patch:
Repository: mdn/kuma

Issue:
T - Add contributions to whoami
During a conversation on the https://github.com/mdn/kuma/pull/7188#issuecomment-637707101 for https://github.com/mdn/kuma/issues/7077 it was decided to only show the `Contributions` link in the usernav for users that have made contributions.

Currently, the `whoami` endpoint does not contain this information.

## Acceptance Criteria

- [ ] `whoami` endpoind exposes a `wiki_contributions` (integer) property for authenticated users


Discussion:

Resolving patch:
diff --git a/kuma/api/v1/views.py b/kuma/api/v1/views.py
--- a/kuma/api/v1/views.py
+++ b/kuma/api/v1/views.py
@@ -78,6 +78,10 @@ def whoami(request):
             data["is_superuser"] = True
         if user.is_beta_tester:
             data["is_beta_tester"] = True
+
+        # This is rather temporary field. Once we're off the Wiki and into Yari
+        # this no longer makes sense to keep.
+        data["wiki_contributions"] = user.created_revisions.count()
     else:
         data = {}
 


Test patch:
diff --git a/kuma/api/v1/tests/test_views.py b/kuma/api/v1/tests/test_views.py
--- a/kuma/api/v1/tests/test_views.py
+++ b/kuma/api/v1/tests/test_views.py
@@ -109,6 +109,8 @@ def test_whoami(
             "samples": {"sample_always": True},
         },
         "email": "wiki_user@example.com",
+        # TODO Remove this once we're off the Wiki.
+        "wiki_contributions": 0,
     }
     if is_staff:
         expect["is_staff"] = True
Repository: mdn/kuma

Issue:
T - Stream of "Refusing to deserialize disabled content of type pickle" errors on prod celery-workers
**Summary**
Each of the prod Celery workers log a steady stream of these errors:

`ERROR/MainProcess] Refusing to deserialize disabled content of type pickle (application/x-python-serialize)`

even though all of the message queues are empty. We don't know why this is happening, and seems to have been happening for at least the past few days (based on Papertrail).



Discussion:
Yep, this is still happening. A lot. I've never seen this locally in `docker-compose`. In Papertrail it's happening over and over. It's happening so often and frequently in Celery that I wonder if something is stuck in an infinite loop of it never getting out. 

We have `CELERY_RESULT_SERIALIZER = "pickle"` and `CELERY_EVENT_SERIALIZER = "pickle"`and `CELERY_ACCEPT_CONTENT = ["pickle"]` meaning we're 100% using pickle for everything between Django and celery. So why would it have a beef with it? 
(Yes, I wish we were 100% JSON but it is what it is with history etc)

No idea where it could have come from then. 
Timebox investigate for a day and reassess how difficult this is.
It's definitely **still happening**: https://my.papertrailapp.com/groups/10501011/events?q=mdn-prod_celery-worker
It's **not** happening on stage: https://my.papertrailapp.com/groups/10501011/events?q=mdn-stage_celery-worker

@escattone Can we just drain the queue on prod celery? 

Perhaps we can take this opportunity to use poetry to upgrade kumbu, celery, billiard and all of those guys to the latest version (for django 2.11) and at least have that in our backs. 

Resolving patch:
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -1332,7 +1332,7 @@ def parse_iframe_url(url):
 # Just remember, avoid passing types that are non-trivial and is
 # different in pickle vs json. Keep things simple. Even if it means
 # you have to do type conversions in the tasks' code.
-CELERY_ACCEPT_CONTENT = ["pickle"]
+CELERY_ACCEPT_CONTENT = ["pickle", "application/x-python-serialize"]
 CELERY_TASK_SERIALIZER = "pickle"
 CELERY_RESULT_SERIALIZER = "pickle"
 CELERY_EVENT_SERIALIZER = "pickle"


Test patch:
Repository: mdn/kuma

Issue:
T - l10n survey
Need to add the l10n survey to MDN using the same banner mechanics as needs assessment and subscriptions.

Wording and layout provided by @malqinneh via Slack:

![988D72B8-5116-4CCB-9D3D-37C7735035B9](https://user-images.githubusercontent.com/10350960/86890396-8d69c700-c0fd-11ea-9490-e58a60bb5a4e.png)

## Acceptance Criteria

- [ ] l10n survey live on all MDN pages as a dismissable banner in the footer of the viewport
- [ ] Able to turn the survey on and off via the waffle flag l10n-survey


Discussion:

Resolving patch:
diff --git a/kuma/core/migrations/0006_create_l10n_survey_banner_flag.py b/kuma/core/migrations/0006_create_l10n_survey_banner_flag.py
new file mode 100644
--- /dev/null
+++ b/kuma/core/migrations/0006_create_l10n_survey_banner_flag.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+def create_l10n_survey_banner_flag(apps, schema_editor):
+    Flag = apps.get_model("waffle", "Flag")
+    if not Flag.objects.filter(name="l10n_survey").exists():
+        Flag.objects.create(
+            name="l10n_survey", staff=True, note="Shows the l10n survey banner"
+        )
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("core", "0005_auto_20200409_1312"),
+        # This is needed otherwise `apps.get_model('waffle', 'Flag')`
+        # will raise a Django app LookupError.
+        ("waffle", "0001_initial"),
+    ]
+
+    operations = [migrations.RunPython(create_l10n_survey_banner_flag)]
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -692,6 +692,10 @@ def pipeline_one_scss(slug, **kwargs):
         "source_filenames": ("styles/components/banners/developer-needs.scss",),
         "output_filename": "build/styles/developer-needs.css",
     },
+    "banner_l10n_survey": {
+        "source_filenames": ("styles/components/banners/l10n-survey.scss",),
+        "output_filename": "build/styles/l10n-survey.css",
+    },
     "banner_mdn_subscriptions": {
         "source_filenames": ("styles/components/banners/mdn-subscriptions.scss",),
         "output_filename": "build/styles/mdn-subscriptions.css",


Test patch:
Repository: mdn/kuma

Issue:
Remove Janet Swisher's name from account welcome emails
**Summary**
When a user signs up, the welcome email message they receive should not contain Janet Swisher's name.

**Rationale**
Janet will no longer be on MDN staff.

**Audience**
Users signing up for accounts

**Proposal**
Remove Janet's name from the "From" field, and from the body of the message. Your call on what to do instead. You could use someone else's name, or "MDN team", or something else. Might want to switch back to a no-reply address if no one will be responding to people who reply to the welcome email.

**Additional context**
I'll miss y'all very much. 



Discussion:
I think it'd be to time-complex to pick another human's name so I'll go with "MDN team" for now. I think it's a bit better than "MDN" or anything else really that doesn't feel human. 

Resolving patch:
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -1578,8 +1578,7 @@ def parse_iframe_url(url):
 
 # Email address from which welcome emails will be sent
 WELCOME_EMAIL_FROM = config(
-    "WELCOME_EMAIL_FROM",
-    default="Janet Swisher - MDN Community Lead <mdn-admins@mozilla.org>",
+    "WELCOME_EMAIL_FROM", default="MDN team <mdn-admins@mozilla.org>",
 )
 # If this fails, SMTP will probably also fail.
 # E.g. https://github.com/mdn/kuma/issues/7121


Test patch:
Repository: mdn/kuma

Issue:
Soapbox banner required for 2020 MDN Web DNA Survey
# Content Issue
<!-- Select the appropriate option -->
- [ ] Please close this issue, I accidentally submitted it without adding any details
- [ ] New documentation
- [x] Correction or update

# URL of page you are seeing the problem on:

All MDN pages!

# Details

We want to launch the 2020 MDN Web DNA Survey on September 18th, and to coincide with it, we want to put a soapbox banner on MDN, inviting people to fill it out.

Last year's call to action text was:

> We have an opportunity for you to influence how browser vendors like Mozilla, Google, Microsoft, and Samsung prioritize feature development.

> It’s easy to take part, just complete this survey that was designed in collaboration with those browser vendors and the W3C. It will take you approximately 20 minutes — this is your chance to make yourself heard. The results and learnings will be shared publicly on MDN.

> You must be 18 years old or over to participate. We handle your information as described in the Mozilla Privacy Policy.

The actual banner text will probably be similar to last year's, something like:

> MDN Web DNA
> Help us understand the top 10 needs of web designers and developers.
> Take the survey.

Let us know what else you need for this. Thanks!


Discussion:

Resolving patch:
diff --git a/kuma/core/migrations/0009_remove_user_interviews_banner_flag.py b/kuma/core/migrations/0009_remove_user_interviews_banner_flag.py
new file mode 100644
--- /dev/null
+++ b/kuma/core/migrations/0009_remove_user_interviews_banner_flag.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+def remove_user_interviews_banner_flag(apps, schema_editor):
+    Flag = apps.get_model("waffle", "Flag")
+    Flag.objects.filter(name="user_interviews").delete()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("core", "0008_remove_l10n_survey_banner_flag"),
+        # This is needed otherwise `apps.get_model('waffle', 'Flag')`
+        # will raise a Django app LookupError.
+        ("waffle", "0001_initial"),
+    ]
+
+    operations = [migrations.RunPython(remove_user_interviews_banner_flag)]
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -692,10 +692,6 @@ def pipeline_one_scss(slug, **kwargs):
         "source_filenames": ("styles/components/banners/developer-needs.scss",),
         "output_filename": "build/styles/developer-needs.css",
     },
-    "banner_user_interviews": {
-        "source_filenames": ("styles/components/banners/user-interviews.scss",),
-        "output_filename": "build/styles/user-interviews.css",
-    },
     "banner_mdn_subscriptions": {
         "source_filenames": ("styles/components/banners/mdn-subscriptions.scss",),
         "output_filename": "build/styles/mdn-subscriptions.css",


Test patch:
Repository: mdn/kuma

Issue:
Disable the payments endpoint
Requested by @chrisdavidmills via Slack:

> Hey folks! Could we please hide this page — https://developer.mozilla.org/en-US/payments/ ? People keep finding it and asking how they can use it to support us



Discussion:

Resolving patch:
diff --git a/kuma/payments/views.py b/kuma/payments/views.py
--- a/kuma/payments/views.py
+++ b/kuma/payments/views.py
@@ -1,5 +1,7 @@
 import logging
 
+from django.conf import settings
+from django.http import Http404
 from django.shortcuts import render
 from django.views.decorators.cache import never_cache
 from waffle.decorators import waffle_flag
@@ -12,6 +14,8 @@
 
 @never_cache
 def index(request):
+    if not settings.ENABLE_SUBSCRIPTIONS:
+        raise Http404("Not enabled")
     highest_subscriber_number = User.get_highest_subscriber_number()
     context = {"next_subscriber_number": highest_subscriber_number + 1}
     return render(request, "payments/index.html", context)
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -1908,3 +1908,9 @@ def get_user_url(user):
 ADDITIONAL_NEXT_URL_ALLOWED_HOSTS = config(
     "ADDITIONAL_NEXT_URL_ALLOWED_HOSTS", default=None
 )
+
+# As of Oct 2020, we might not enable subscriptions at all. There are certain
+# elements of Kuma that exposes subscriptions even if all the Waffle flags and
+# switches says otherwise. For example, the payments pages are skeletons for
+# React apps. This boolean settings disables all of that.
+ENABLE_SUBSCRIPTIONS = config("ENABLE_SUBSCRIPTIONS", cast=bool, default=False)
diff --git a/kuma/settings/pytest.py b/kuma/settings/pytest.py
--- a/kuma/settings/pytest.py
+++ b/kuma/settings/pytest.py
@@ -105,3 +105,7 @@
 
 SENDINBLUE_API_KEY = "testing"
 SENDINBLUE_LIST_ID = 7327
+
+# This is False by default, to so we don't have to rewrite all the existing
+# tests, it's True in this context.
+ENABLE_SUBSCRIPTIONS = True


Test patch:
diff --git a/kuma/payments/tests/test_views.py b/kuma/payments/tests/test_views.py
--- a/kuma/payments/tests/test_views.py
+++ b/kuma/payments/tests/test_views.py
@@ -16,6 +16,15 @@ def test_payments_index(client, settings):
     assert doc(".subscriptions h2").text() == "You will be MDN member number 1"
 
 
+@pytest.mark.django_db
+def test_payments_index_disabled(client, settings):
+    """Viewing the payments index page doesn't require you to be logged in.
+    Payments page shows support email and header."""
+    settings.ENABLE_SUBSCRIPTIONS = False
+    response = client.get(reverse("payments_index"))
+    assert response.status_code == 404
+
+
 @pytest.mark.django_db
 def test_payments_url_fixes(client):
     """These tests just make sure that the use of trailing slashes are correct."""
Repository: mdn/kuma

Issue:
Changing your locale on the Edit Profile should set a preferredlocale cookie
**Summary**
When you click to "Edit profile" and change your language, it shouldn't just update your session cookie profile, but it should also set a non-HTTP cookie which that works like [we're doing it in Yari](https://github.com/mdn/yari/blob/70f3bef86d5563501627a7b598215b7d21c6eb3b/client/src/ui/molecules/language-menu/index.tsx#L46-L52).


**Audience**
Anybody using MDN and has an account, GitHub or Google. 


**Rationale**
It makes sense. You can always change your preferred language by using the language drop-down. But what if the user doesn't realize that and they click their "Edit profile" to change it. And can you imagine the disappointment if that doesn't work? :)


**Workaround**
Wait until we rewrite the View and Edit profile as Yari SPAs.


**Proposal**
A little one-liner in the `users/views.py` that sets the cookie in the same way that Yari's language-dropdown does it.


**Additional context**
https://github.com/mdn/kuma/pull/7670



Discussion:

Resolving patch:
diff --git a/kuma/users/views.py b/kuma/users/views.py
--- a/kuma/users/views.py
+++ b/kuma/users/views.py
@@ -473,7 +473,16 @@ def user_edit(request, username):
                 # If there's no Beta Testers group, ignore that logic
                 pass
 
-            return redirect(edit_user)
+            response = redirect(edit_user)
+            if edit_user.locale:
+                response.set_cookie(
+                    key=settings.LANGUAGE_COOKIE_NAME,
+                    value=edit_user.locale,
+                    max_age=settings.LANGUAGE_COOKIE_AGE,
+                    path=settings.LANGUAGE_COOKIE_PATH,
+                    domain=settings.LANGUAGE_COOKIE_DOMAIN,
+                )
+            return response
 
     # Needed so the template can know to show a warning message and the
     # template doesn't want to do code logic to look into the 'request' object.


Test patch: