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

Review and document ngclient exceptions #1787

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

MVrachev
Copy link
Collaborator

Fixes #1312

Description of the changes being introduced by the pull request:

I made a review on all files inside tuf/ngclient to see which of them
needs additions or changes in their function docstrings regarding
exceptions.

I didn't find any changes required inside the request_fetcher.py
and of course inside the config module.
Other than that multiple additions had to be made.

For trusted_metadata_set.py we had a discussion with Jussi that there is
no need to list each of the specific RepositoryErrors one by one as
this is an internal module and this will only create a bigger
maintenance burden.

For updater.py we had discussions with Jussi and Lukas that we want to
document only those exceptions that could be potentially handled.
This means there is no point in documenting each of the RepositoryErrors
or DownloadErrors separately.

Finally, I added a little documentation for download_bytes() inside
fetcher.py, as it's naming, suggests it's not an internal function.

Signed-off-by: Martin Vrachev mvrachev@vmware.com

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

We no longer need to catch LengthOrHashMismatchError and reraise a
RepositoryError as LengthOrHashMismatchError is changed to inherit
RepositoryError.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
@MVrachev
Copy link
Collaborator Author

@lukpueh can you investigate why still there are required CI builds for python3.6?

@coveralls
Copy link

coveralls commented Jan 20, 2022

Pull Request Test Coverage Report for Build 1756233091

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.1%) to 97.571%

Files with Coverage Reduction New Missed Lines %
tuf/developer_tool.py 1 92.8%
tuf/client/updater.py 2 98.6%
Totals Coverage Status
Change from base Build 1745632739: -0.1%
Covered Lines: 4080
Relevant Lines: 4164

💛 - Coveralls

Copy link
Collaborator

@kairoaraujo kairoaraujo left a comment

Choose a reason for hiding this comment

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

IMHO the raise message is more straightforward than the docstring for RuntimeError in the functions.
But I'm still unable to get better suggestions (Sorry), maybe more detailed information as the raising messages?

@MVrachev
Copy link
Collaborator Author

IMHO the raise message is more straightforward than the docstring for RuntimeError in the functions. But I'm still unable to get better suggestions (Sorry), maybe more detailed information as the raising messages?

Do you mean that the rest of the documentation regarding exceptions in Raises is more straightforward than the one I have added for RuntimeErrors?
Can you elaborate more on that?

@kairoaraujo
Copy link
Collaborator

Do you mean that the rest of the documentation regarding exceptions in Raises is more straightforward than the one I have added for RuntimeErrors? Can you elaborate more on that?

What I mean is that messages raises are more straightforward than the one in the docstrings.

raise RuntimeError("Cannot update timestamp after snapshot")
raise RuntimeError("Cannot update snapshot before timestamp")
raise RuntimeError("Cannot update snapshot after targets")
raise RuntimeError("Cannot load targets before snapshot")
raise RuntimeError("Cannot load targets before delegator")

Maybe it is my interpretation, but reading the raised messages (not the code logic) gives me more details than the documentation.

@lukpueh
Copy link
Member

lukpueh commented Jan 21, 2022

@lukpueh can you investigate why still there are required CI builds for python3.6?

Oh sure. I had to kick out the 3.6 checks in the branch protection rules.

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

I agree with the core choices here: figuring out if we really cover everything with the exceptions docstrings is really hard but I couldn't find anything where I disagreed with you.

lefty some very nitpicky comments (which are really up to you), and then the one about writing the file: raising OSError manually feels wrong... I'd rather we skip the securesystemslib function call altogether.

tuf/ngclient/fetcher.py Outdated Show resolved Hide resolved
tuf/ngclient/updater.py Outdated Show resolved Hide resolved
tuf/ngclient/_internal/trusted_metadata_set.py Outdated Show resolved Hide resolved
tuf/ngclient/fetcher.py Outdated Show resolved Hide resolved
@MVrachev MVrachev force-pushed the ngclient-exceptions branch 2 times, most recently from 4ba8751 to 6403d13 Compare January 27, 2022 12:33
@MVrachev MVrachev requested a review from jku January 27, 2022 12:34
I made a review on all files inside tuf/ngclient to see which of them
needs additions or changes in their function docstrings regarding
exceptions.

I didn't find any changes required inside the request_fetcher.py
and of course inside the config module.
Other than that multiple additions had to be made.

For trusted_metadata_set we had a discussion with Jussi that there is
no need to list each of the specific RepositoryErrors one by one as
this is an internal module and this will only create a bigger
maintenance burden.

For updater.py we had discussions with Jussi and Lukas that we want to
document only those exceptions that could be potentially handled.
This means there is no point in documenting each of the RepositoryErrors
or DownloadErrors separately.

Finally, I added a little documentation for download_bytes() inside
fetcher.py, as it's naming, suggests it's not an internal function.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
@MVrachev
Copy link
Collaborator Author

@jku can we merge this pr first and then #1799?
As this pr and #1799 touch updater.download_target() I want to make sure that after we merge both of the prs the correct exception docstring will be there.

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks.

@lukpueh lukpueh merged commit d95ead6 into theupdateframework:develop Jan 27, 2022
@MVrachev MVrachev deleted the ngclient-exceptions branch January 27, 2022 13:33
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.

review/document client exceptions
5 participants