Skip to content

Conversation

@ssbarnea
Copy link

@ssbarnea ssbarnea commented Feb 9, 2019

Fix issues where essential error about paramiko dealing code was
lost due to ageneric exception that assumed paramiko library was
missing.

To keep backwards compatibility we keep the custom exception but we
also include information from original exception that caused it.

It was wrong to believe that only missing paramiko can cause it, even
code inside docker-py can thow exceptions, and NamedException is very
broad exception class.

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "fix/improve-ssh-error" [email protected]:ssbarnea/docker-py.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

Fix issues where essential error about paramiko dealing code was
lost due to ageneric exception that assumed paramiko library was
missing.

To keep backwards compatibility we keep the custom exception but we
also include information from original exception that caused it.

It was wrong to believe that only missing paramiko can cause it, even
code inside docker-py can thow exceptions, and NamedException is very
broad exception class.

Signed-off-by: Sorin Sbarnea <[email protected]>
)
except NameError:
except NameError as e:
# do not hide orriginal exception as it may contain important info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: orriginal -> original

# do not hide orriginal exception as it may contain important info
raise DockerException(
'Install paramiko package to enable ssh:// support'
"Paramiko failure while trying ssh:// protocol:\n%s" % e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if changing the message is necessary here.

@shin-
Copy link
Contributor

shin- commented Mar 16, 2019

@ssbarnea Do you have an example of a NameError being raised on that particular code path that isn't caused by a missing dependency?

My problem with this PR is that I would still like to give clear information to the user in the case they haven't installed the optional paramiko dependency. As such, a better fix may be to catch a more specific error, or to catch it earlier in the callstack to avoid false positives. Making the error message more generic and lower-level is not the right direction, IMO.

@ssbarnea
Copy link
Author

@shin- Yes I encountered that but I do not remember it now. I would rather throw the original error back instead of creating a new one that is crippled of important information. That code is wrong as it makes some dangereus assumptions.

@ulyssessouza
Copy link
Contributor

This PR is not passing due to an already solved problem.
Please rebase your PR with master

@ssbarnea ssbarnea closed this Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants