Ensure SSH is given a valid port number.
Review Request #7619 — Created Sept. 8, 2015 and submitted
When an invalid port is given in a repository path, a cryptic error message was shown.
The change provides a better error message to the user when an invalid port is in the repository path.
Ran unit tests.
Manually verified that the error message was displayed upon replication.
Description | From | Last Updated |
---|---|---|
This doesn't need to be in the try does it? |
brennie | |
What happens if this doesn't pass a list. Also, there is trailing whitespace and this should end with a period. |
brennie | |
SSHError isn't really appropriate in this case because its an error in parsing, not with SSH itself. Can we add … |
brennie | |
Can this include the port number? Also, we use single quotes for strings. |
brennie | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 17 W503 line break before binary operator |
reviewbot | |
This isn't going to work quite correctly, because whatever is passed to _() needs to be a constant. How about … |
david | |
Col: 17 E128 continuation line under-indented for visual indent |
reviewbot | |
I'd call this SSHInvalidPortError, for consistency with the other classes. |
chipx86 | |
Blank line between these. |
chipx86 | |
For docstrings, you should use double quotes. """ |
chipx86 | |
You can combine these into one statement: You should also use super(...) for calling the parent constructor. The other classes … |
chipx86 | |
Make sure these are imported in alphabetical order. |
chipx86 | |
Blank line between these. We always have a blank line between statements and blocks, or blocks and blocks on the … |
chipx86 | |
"path" -> "port" |
mike_conley | |
Elsewhere in this file, instead of using super(class), we seem to directly call into SSHError.__init__. Do we know why that … |
mike_conley | |
You don't need this blank line, since the block is ending. |
chipx86 |
-
-
-
reviewboard/scmtools/forms.py (Diff revision 1) What happens if this doesn't pass a list.
Also, there is trailing whitespace and this should end with a period.
-
I appreciate the change, but we actually don't validate URLs in the form for a very good reason: Repository paths are not always URLs.
Perforce uses paths like myservername:1666.
CVS uses paths like :pserver:username@servername:/cvsroot/foo
Git uses names like git@domain:/path
Even when they are URLs, sometimes they're not fully-qualified domains (so https://myserver/, rather than https://myserver.mycompany.com/), which won't pass the validator.
Repository path validation would need to be done in each SCMTool instead, per their own validation rules.
Right now, we already have a
check_repository()
function thatSCMTool
subclasses can implement, which checks to make sure the URL is accessible. This is where validation logic should go. It should ensure that the path passed in matches expectations, and raise a suitable error (perhaps a newRepositoryPathValidationError
that subclassesSCMError
). The form and API code would need to know to handle this new error.
Summary: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
||||||||||||||||||
Branch: |
|
||||||||||||||||||
Diff: |
Revision 2 (+4 -1) |
-
Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py
-
-
reviewboard/ssh/utils.py (Diff revision 2) Can this include the port number?
Also, we use single quotes for strings.
-
Your description and summary need some work. You may want to give this guide on writing good descriptions a read.
In general, the summary and description should provide information on why the change was necessary.
-
reviewboard/ssh/utils.py (Diff revision 2) SSHError
isn't really appropriate in this case because its an error in parsing, not with SSH itself.Can we add a new error class somewhere that describes a parsing error?
Summary: |
|
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
-
Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
-
-
Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
-
reviewboard/ssh/errors.py (Diff revision 4) This isn't going to work quite correctly, because whatever is passed to
_()
needs to be a constant. How about something like this:msg = (_('"%s" is not a valid port number. Please ensure ' 'the path has a correct port number specified.') % port)
-
Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
reviewboard/ssh/errors.py (Diff revision 5) Col: 17 E128 continuation line under-indented for visual indent
-
Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
-
reviewboard/ssh/errors.py (Diff revision 6) I'd call this
SSHInvalidPortError
, for consistency with the other classes. -
-
-
reviewboard/ssh/errors.py (Diff revision 6) You can combine these into one statement:
You should also use
super(...)
for calling the parent constructor. The other classes don't do this, but only because they used to have to support versions of Python wheresuper()
couldn't be used with exceptions.End result should be like:
super(InvalidSSHPortError, self).__init__( self, _('......' '......') % port)
Note two things about this:
- When dealing with long parameters like this, we're doing one parameter per line.
- The
% var
goes on its own line, aligned with th thing it's formatting, when dealing with wrapped strings.
-
-
reviewboard/ssh/utils.py (Diff revision 6) Blank line between these. We always have a blank line between statements and blocks, or blocks and blocks on the same level.
-
Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
-
-
reviewboard/ssh/errors.py (Diff revision 7) Elsewhere in this file, instead of using super(class), we seem to directly call into SSHError.__init__.
Do we know why that is?
-
Tool: Pyflakes Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py Tool: PEP8 Style Checker Processed Files: reviewboard/ssh/utils.py reviewboard/ssh/errors.py
-
-
reviewboard/ssh/utils.py (Diff revision 8) You don't need this blank line, since the block is ending.