Add error handling for when we can't decrypt stored passwords.
Review Request #14276 — Created Dec. 16, 2024 and submitted
When a repository has a stored password that can not be decrypted
(usually due to theSECRET_KEY
having been changed), we run into some
especially ugly behavior. Any review requests which attempt to access
that repository will just crash entirely with aUnicodeDecodeError
,
and attempting to open the repository form to reset the username and
password will show an empty form because the data cannot be loaded.This change adds some error handling so that if we cannot decrypt the
password, we'll log the error and then returnNone
. This will result
in authentication errors attempting to access the repository, and allows
opening the repository form in the admin to fix it as well.This also fixes the pysvn implementation of normalize_error to pass in
the error message as themsg
parameter to the exception, which makes
it so we don't try to convert that error message to a list for display
(the base SSH authentication error class that SVN auth errors inherit
from has the SSH authentication methods list as its first argument).
Created an authenticated repository with one
SECRET_KEY
and then
changed it.
- Saw that I was able to open the repository settings form and have it
populated with everything except the password. Previously the form
would not only be blank, but the current repository type
("Subversion") wasn't appearing in the tool drop-down at all. - Loaded a review request and diff and saw that instead of getting an
unhandled UnicodeDecodeError exception, I now was able to view the
review request and saw authentication error notices in the diff
content. - Saw that said authentication errors were correctly formatted.
Summary | ID |
---|---|
c35f3acc92a9193544c71b6c3f61efae9c1d011c |
Description | From | Last Updated |
---|---|---|
Can you add unit tests that also check the exception message for some common cases? Say, changed key, corrupt data? |
chipx86 | |
I think we should log the repository ID so it's easier to follow up on this, but we'll want to … |
chipx86 | |
Let's do an assertLogs just to cover that. |
chipx86 | |
'reviewboard.scmtools.models.logger as models_logger' imported but unused Column: 1 Error code: F401 |
reviewbot |
-
-
Can you add unit tests that also check the exception message for some common cases? Say, changed key, corrupt data?
-
I think we should log the repository ID so it's easier to follow up on this, but we'll want to be very careful not to log the value we're decrypting if it comes from the exception (does it? I can't tell).
- Commits:
-
Summary ID 3a417829d63cea2bff3851aa701e3c3632b7b32b db28ebdc50f1de17519fe48e0378719b63c60ddc
Checks run (2 succeeded)
- Commits:
-
Summary ID db28ebdc50f1de17519fe48e0378719b63c60ddc 8dd82b63b30d88b00f006afa08ff62b534c96136