New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added help entry for File already exists error #2997
Conversation
The error message is here, we can update it to include a link to this help section. |
Sure @di Will do |
warehouse/templates/pages/help.html
Outdated
<section id="file-name-reuse" class="common-question"> | ||
<h2>{{ file_name_reuse() }}</h2> | ||
<p> | ||
The error <i>HTTPError: 400 Client Error: File already exists</i> is caused because of one of the below two reasons: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you rephrase as:
The error HTTPError: 400 Client Error: File already exists happens for one of two reasons:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - Will rephrase
warehouse/forklift/legacy.py
Outdated
@@ -1033,7 +1036,8 @@ def file_upload(request): | |||
raise _exc_with_message( | |||
HTTPBadRequest, | |||
"This filename has previously been used, you should use a " | |||
"different version.", | |||
"different version. " | |||
"See https://pypi.org/help/#file-name-reuse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you generate these URLs with request.route_url('help', _anchor='file-name-reuse')
instead? Otherwise these will be wrong for https://test.pypi.org/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, Will address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@di What about _scheme and _host
?
request.route_url('help', _anchor='file-name-reuse')
generates only path right. What about host?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
route_path
would generate a path, like /help/#file-name-reuse
, route_url
generates a fully qualified URL, like https://pypi.org/help/#file-name-reuse
, so you don't need to specify a host or scheme.
@di After I put |
@waseem18 The issue is that your tests don't mock out db_request.route_url = pretend.call_recorder(lambda route, **kw: "/the/help/url/") And then your assertion will become: assert resp.status == (
"400 This filename has previously been used, you should use a "
"different version. See /the/help/url/"
) since we don't actually need to test if |
And, additionally, you can test that assert db_request.route_url.calls == [pretend.call('help', _anchor='file-name-reuse')] |
@waseem18 I thought you might want some tips on tidying your commit history, including updating your commit messages. And when you update your code or your commit message, you can update your pull request and the changes will appear here. :) (I love the Zulip docs for these tips!) |
Thanks for the links @brainwane |
Thanks @waseem18! |
Fixes #2701.
Need to add link to help entry in the the error message. I guess this change goes into
twine
.