Skip to content

Commit aadb7f6

Browse files
brainwanedi
authored andcommitted
Advise packagers on requesting upload size limit increase (#3175)
* Advise packagers on requesting upload size limit increase * Add filesize limit help link to error message * Fix typo in comment
1 parent 1ce7b63 commit aadb7f6

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

tests/unit/forklift/test_legacy.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1548,15 +1548,22 @@ def test_upload_fails_with_too_large_file(self, pyramid_config,
15481548
type="application/tar",
15491549
),
15501550
})
1551+
db_request.route_url = pretend.call_recorder(
1552+
lambda route, **kw: "/the/help/url/"
1553+
)
15511554

15521555
with pytest.raises(HTTPBadRequest) as excinfo:
15531556
legacy.file_upload(db_request)
15541557

15551558
resp = excinfo.value
15561559

1560+
assert db_request.route_url.calls == [
1561+
pretend.call('help', _anchor='file-size-limit')
1562+
]
15571563
assert resp.status_code == 400
15581564
assert resp.status == (
1559-
"400 File too large. Limit for project 'foobar' is 60MB"
1565+
"400 File too large. Limit for project 'foobar' is 60MB. "
1566+
"See /the/help/url/"
15601567
)
15611568

15621569
def test_upload_fails_with_too_large_signature(self, pyramid_config,

warehouse/forklift/legacy.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ def file_upload(request):
966966
request.POST["content"].type.startswith("image/")):
967967
raise _exc_with_message(HTTPBadRequest, "Invalid distribution file.")
968968

969-
# Ensure that the package filetpye is allowed.
969+
# Ensure that the package filetype is allowed.
970970
# TODO: Once PEP 527 is completely implemented we should be able to delete
971971
# this and just move it into the form itself.
972972
if (not project.allow_legacy_files and
@@ -997,10 +997,14 @@ def file_upload(request):
997997
raise _exc_with_message(
998998
HTTPBadRequest,
999999
"File too large. " +
1000-
"Limit for project {name!r} is {limit}MB".format(
1000+
"Limit for project {name!r} is {limit}MB. ".format(
10011001
name=project.name,
1002-
limit=file_size_limit // (1024 * 1024),
1003-
))
1002+
limit=file_size_limit // (1024 * 1024)) +
1003+
"See " +
1004+
request.route_url(
1005+
'help', _anchor='file-size-limit'
1006+
),
1007+
)
10041008
fp.write(chunk)
10051009
for hasher in file_hashes.values():
10061010
hasher.update(chunk)

warehouse/templates/pages/help.html

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
{% macro preproduction() %}What does pre-production mean?{% endmacro %}
3131
{% macro project_name() %}Why isn't my desired project name available?{% endmacro %}
3232
{% macro project_name_claim() %}How do I claim an abandoned or previously registered project name?{% endmacro %}
33+
{% macro file_size_limit() %}How do I get a file size limit exemption or increase for my project?{% endmacro %}
3334
{% macro verified_email() %}Why do I need a verified email address?{% endmacro %}
3435
{% macro maintainers() %}Who maintains PyPI?{% endmacro %}
3536
{% macro sponsors() %}What powers PyPI?{% endmacro %}
@@ -54,6 +55,7 @@ <h1 class="page-title">Common Questions</h1>
5455
<li><a href="#preproduction">{{ preproduction() }}</a></li>
5556
<li><a href="#project-name">{{ project_name() }}</a></li>
5657
<li><a href="#project-name-claim">{{ project_name_claim() }}</a></li>
58+
<li><a href="#file-size-limit">{{ file_size_limit() }}</a></li>
5759
<li><a href="#verified-email">{{ verified_email() }}</a></li>
5860
<li><a href="#maintainers">{{ maintainers() }}</a></li>
5961
<li><a href="#accessibility">{{ accessibility() }}</a></li>
@@ -154,6 +156,17 @@ <h2>{{ project_name_claim() }}</h2>
154156
</p>
155157
</section>
156158

159+
<section id="file-size-limit" class="common-question">
160+
<h2>{{ file_size_limit() }}</h2>
161+
<p>
162+
If you can't upload your project's release to PyPI because you're hitting the upload file size limit, we can sometimes increase your limit. Please make sure you've uploaded at least one release for the project that's <i>under</i> the limit (a <a href="https://www.python.org/dev/peps/pep-0440/#developmental-releases">developmental release version number</a> is fine). Then, please <a href="https://github.com/pypa/warehouse/issues/new">file an issue</a> and tell us:</p>
163+
<ul>
164+
<li>The name of the project</li>
165+
<li>The size of your release, in megabytes</li>
166+
<li>Which index/indexes you need the increase for (PyPI, Test PyPI, or both)</li>
167+
</ul>
168+
</section>
169+
157170
<section id="verified-email" class="common-question">
158171
<h2>{{ verified_email() }}</h2>
159172
<p>

0 commit comments

Comments
 (0)