Skip to content
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

Improve error handling in support code for cryptography backend #139

Merged

Conversation

felixfontein
Copy link
Contributor

SUMMARY

If a ValueError is raised, convert it to a OpenSSLObjectError instead of letting the caller code crash on the unexpected exception type.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/module_utils/crypto/support.py

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

You didn't change the logic, only added raising a better type of error, did you?
If the logic was changed, are the related code parts covered by tests?

changelogs/fragments/139-improve-error-handling.yml Outdated Show resolved Hide resolved
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
@felixfontein
Copy link
Contributor Author

The logic should not change at all, there's only one more try/except in load_certificate and load_certificate_request, which converts ValueErrors raised by cryptography to OpenSSLObjectError's.

(In load_privatekey, the IOError/OSError catch now only covers the part which actually reads the file. It's not needed for the rest.)

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

the GH representation looks a bit messy in this case, ok:)
LGTM

@felixfontein
Copy link
Contributor Author

It does indeed! I mostly unindented a whole block, but the diff just looks horrible ;)

@felixfontein felixfontein merged commit 77d652d into ansible-collections:main Nov 10, 2020
@felixfontein felixfontein deleted the improve-error-handling branch November 10, 2020 09:47
@felixfontein
Copy link
Contributor Author

@Andersson007 thanks for reviewing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants