-
Notifications
You must be signed in to change notification settings - Fork 188
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
InstalledCode
: Fix bug in validate_filepath_executable
for SSH
#5787
InstalledCode
: Fix bug in validate_filepath_executable
for SSH
#5787
Conversation
This bug was discovered in today's hackathon. It only occurs for a computer with |
8ed6f71
to
0186c3f
Compare
511ecf7
to
4275455
Compare
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.
thanks @sphuber ! just one question
@@ -72,11 +72,11 @@ def validate_filepath_executable(self): | |||
try: | |||
with override_log_level(): # Temporarily suppress noisy logging | |||
with self.computer.get_transport() as transport: | |||
file_exists = transport.isfile(self.filepath_executable) | |||
except Exception: # pylint: disable=broad-except | |||
file_exists = transport.isfile(str(self.filepath_executable)) |
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.
If local
returned a str
here and ssh
a Path
, should we then not also aim to harmonize the behavior of the filepath_executable
property?
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.
They both returned a pathlib.Path
, the problem is that LocalTransport.isfile
accepts a pathlib.Path
, whereas SshTransport
only accepts strings. We should probably update the transport interfaces to add support for pathlib.Path
objects.
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.
Thanks - yes, that would make sense. Up to you whether you want to do it here or not
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 think it is better to do the whole interface in one go. Have opened a feature request for it #5797
If the code was attached to a `Computer` with `core.ssh` transport, the `validate_filepath_executable` would always return that the computer could not be connected to. This is because the actual exception that was caught does not come from `Computer.get_transport` but is a `TypeError` raised by `transport.isfile` since it receives a `pathlib.Path` were it expects a `str`. The problem went undetected since it only tested against a computer with `core.local` transport. A new test is added to also test against a computer with `core.ssh` transport`.
4275455
to
6af9422
Compare
Fixes #5795
If the code was attached to a
Computer
withcore.ssh
transport, thevalidate_filepath_executable
would always return that the computercould not be connected to. This is because the actual exception that was
caught does not come from
Computer.get_transport
but is aTypeError
raised by
transport.isfile
since it receives apathlib.Path
were itexpects a
str
.The problem went undetected since it only tested against a computer with
core.local
transport. A new test is added to also test against acomputer with
core.ssh
transport`.