Repository: pypi/warehouse

Issue:
Received "500: Internal Server Error" Package upload appears to have failed.
<!--
    NOTE: This issue should be for problems with PyPI itself, including:
    * pypi.org
    * test.pypi.org
    * files.pythonhosted.org

    This issue should NOT be for a project installed from PyPI. If you are
    having an issue with a specific package, you should reach out to the
    maintainers of that project directly instead.

    Furthermore, this issue should NOT be for any non-PyPI properties (like
    python.org, docs.python.org, etc.)

    If your problem is related to search (a new or updated project doesn't
    appear in the PyPI search results), please wait for a couple of hours
    and check again before reporting it. The search index may take some
    time to be updated.
-->

I try to upload a package to PIP in the standard way:

     twine upload dist/*

It worked in the past, but now all I get is:

```
Uploading dynprog-0.1.2-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████| 26.0k/26.0k [00:00<00:00, 27.2kB/s]
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 1 of 5
Uploading dynprog-0.1.2-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████| 26.0k/26.0k [00:00<00:00, 95.0kB/s] 
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 2 of 5
Uploading dynprog-0.1.2-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████| 26.0k/26.0k [00:00<00:00, 83.5kB/s] 
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 3 of 5
Uploading dynprog-0.1.2-py3-none-any.whl
100%|██████████████████████████████████████████████████████████████████| 26.0k/26.0k [00:00<00:00, 104kB/s] 
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 4 of 5
Uploading dynprog-0.1.2-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████| 26.0k/26.0k [00:00<00:00, 98.4kB/s] 
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 5 of 5

500 Internal Server Error
<html>
  <head>
    <title>Internal Server Error</title>
  </head>
  <body>
    <h1><p>Internal Server Error</p></h1>

  </body>
</html>

HTTPError: 500 Internal Server Error from https://upload.pypi.org/legacy/
Internal Server Error
```

**Expected behavior**
I expected to get a more detailed error message, so that I can understand what is wrong with my package.

**To Reproduce**
Unzip the attached file. Then run `twine upload dist/*`.

**My Platform**
Windows 10, standard ADSL Internet connection.
[dist.zip](https://github.com/pypa/warehouse/files/8042027/dist.zip)




Discussion:

Resolving patch:
diff --git a/warehouse/accounts/__init__.py b/warehouse/accounts/__init__.py
--- a/warehouse/accounts/__init__.py
+++ b/warehouse/accounts/__init__.py
@@ -77,7 +77,6 @@ def _basic_auth_login(username, password, request):
         elif login_service.check_password(
             user.id,
             password,
-            request.remote_addr,
             tags=["mechanism:basic_auth", "method:auth", "auth_method:basic"],
         ):
             if breach_service.check_password(
diff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py
--- a/warehouse/accounts/views.py
+++ b/warehouse/accounts/views.py
@@ -532,9 +532,7 @@ def register(request, _form_class=RegistrationForm):
         user = user_service.create_user(
             form.username.data, form.full_name.data, form.new_password.data
         )
-        email = user_service.add_email(
-            user.id, form.email.data, request.remote_addr, primary=True
-        )
+        email = user_service.add_email(user.id, form.email.data, primary=True)
         user_service.record_event(
             user.id,
             tag="account:create",


Test patch:
diff --git a/tests/unit/accounts/test_core.py b/tests/unit/accounts/test_core.py
--- a/tests/unit/accounts/test_core.py
+++ b/tests/unit/accounts/test_core.py
@@ -62,7 +62,7 @@ def test_with_invalid_password(self, pyramid_request, pyramid_services):
             get_user=pretend.call_recorder(lambda user_id: user),
             find_userid=pretend.call_recorder(lambda username: 1),
             check_password=pretend.call_recorder(
-                lambda userid, password, ip_address, tags=None: False
+                lambda userid, password, tags=None: False
             ),
             is_disabled=pretend.call_recorder(lambda user_id: (False, None)),
         )
@@ -89,7 +89,6 @@ def test_with_invalid_password(self, pyramid_request, pyramid_services):
             pretend.call(
                 1,
                 "mypass",
-                "1.2.3.4",
                 tags=["mechanism:basic_auth", "method:auth", "auth_method:basic"],
             )
         ]
@@ -110,7 +109,7 @@ def test_with_disabled_user_no_reason(self, pyramid_request, pyramid_services):
             get_user=pretend.call_recorder(lambda user_id: user),
             find_userid=pretend.call_recorder(lambda username: 1),
             check_password=pretend.call_recorder(
-                lambda userid, password, ip_address, tags=None: False
+                lambda userid, password, tags=None: False
             ),
             is_disabled=pretend.call_recorder(lambda user_id: (True, None)),
         )
@@ -137,7 +136,6 @@ def test_with_disabled_user_no_reason(self, pyramid_request, pyramid_services):
             pretend.call(
                 1,
                 "mypass",
-                "1.2.3.4",
                 tags=["mechanism:basic_auth", "method:auth", "auth_method:basic"],
             )
         ]
@@ -155,7 +153,7 @@ def test_with_disabled_user_compromised_pw(self, pyramid_request, pyramid_servic
             get_user=pretend.call_recorder(lambda user_id: user),
             find_userid=pretend.call_recorder(lambda username: 1),
             check_password=pretend.call_recorder(
-                lambda userid, password, ip_address, tags=None: False
+                lambda userid, password, tags=None: False
             ),
             is_disabled=pretend.call_recorder(
                 lambda user_id: (True, DisableReason.CompromisedPassword)
@@ -190,7 +188,7 @@ def test_with_valid_password(self, monkeypatch, pyramid_request, pyramid_service
             get_user=pretend.call_recorder(lambda user_id: user),
             find_userid=pretend.call_recorder(lambda username: 2),
             check_password=pretend.call_recorder(
-                lambda userid, password, ip_address, tags=None: True
+                lambda userid, password, tags=None: True
             ),
             update_user=pretend.call_recorder(lambda userid, last_login: None),
             is_disabled=pretend.call_recorder(lambda user_id: (False, None)),
@@ -221,7 +219,6 @@ def test_with_valid_password(self, monkeypatch, pyramid_request, pyramid_service
             pretend.call(
                 2,
                 "mypass",
-                "1.2.3.4",
                 tags=["mechanism:basic_auth", "method:auth", "auth_method:basic"],
             )
         ]
@@ -244,7 +241,7 @@ def test_via_basic_auth_compromised(
             get_user=pretend.call_recorder(lambda user_id: user),
             find_userid=pretend.call_recorder(lambda username: 2),
             check_password=pretend.call_recorder(
-                lambda userid, password, ip_address, tags=None: True
+                lambda userid, password, tags=None: True
             ),
             is_disabled=pretend.call_recorder(lambda user_id: (False, None)),
             disable_password=pretend.call_recorder(lambda user_id, reason=None: None),
@@ -272,7 +269,6 @@ def test_via_basic_auth_compromised(
             pretend.call(
                 2,
                 "mypass",
-                "1.2.3.4",
                 tags=["mechanism:basic_auth", "method:auth", "auth_method:basic"],
             )
         ]
diff --git a/tests/unit/accounts/test_views.py b/tests/unit/accounts/test_views.py
--- a/tests/unit/accounts/test_views.py
+++ b/tests/unit/accounts/test_views.py
@@ -1279,9 +1279,7 @@ def test_register_redirect(self, db_request, monkeypatch):
         assert create_user.calls == [
             pretend.call("username_value", "full_name", "MyStr0ng!shP455w0rd")
         ]
-        assert add_email.calls == [
-            pretend.call(user.id, "foo@bar.com", db_request.remote_addr, primary=True)
-        ]
+        assert add_email.calls == [pretend.call(user.id, "foo@bar.com", primary=True)]
         assert send_email.calls == [pretend.call(db_request, (user, email))]
         assert record_event.calls == [
             pretend.call(