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
Add docs for ActiveSupport::EncryptedFile#read [ci-skip] #45570
Add docs for ActiveSupport::EncryptedFile#read [ci-skip] #45570
Conversation
@@ -49,6 +49,9 @@ def key | |||
read_env_key || read_key_file || handle_missing_key | |||
end | |||
|
|||
# Read and return decrypted content |
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.
# Read and return decrypted content | |
# Reads the file and returns the decrypted content. |
@@ -49,6 +49,9 @@ def key | |||
read_env_key || read_key_file || handle_missing_key | |||
end | |||
|
|||
# Read and return decrypted content | |||
# | |||
# Raise <tt>MissingContentError</tt> if unable to decrypt content |
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.
This method can raise other errors as well. For example, if raise_if_missing_key
is true and the key is missing then the key.nil?
call will raise MissingKeyError
. Plus any errors due to an incorrect key or wrong file contents.
Also, we can link MissingContentError
to its own API documentation by omitting <tt>
.
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 for pointing that out. I'll add that and any additional errors I see in EncryptedFile
to the documentation.
I also noticed that decrypt
can raise ActiveSupport::MessageEncryptor::InvalidMessage
, is it customary to also include that as part of documentation? Thanks.
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.
Yes, let's include ActiveSupport::MessageEncryptor::InvalidMessage
too.
236ec14
to
eef6065
Compare
# Raises: | ||
# - MissingContentError if unable to decrypt content. | ||
# - MissingKeyError if key is missing and <tt>raise_if_missing_key</tt> is true. | ||
# - InvalidKeyLengthError if key length is invalid. |
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.
read
does not raise InvalidKeyLengthError
. (write
/ encrypt
does.)
# - InvalidKeyLengthError if key length is invalid. |
# - MissingContentError if unable to decrypt content. | ||
# - MissingKeyError if key is missing and <tt>raise_if_missing_key</tt> is true. |
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.
MissingContentError
is primarily for when the encrypted file is missing, though it will be raised if the key is missing and a MissingKeyError
has not already been raised. Therefore, let's put these in chronological order:
# - MissingContentError if unable to decrypt content. | |
# - MissingKeyError if key is missing and <tt>raise_if_missing_key</tt> is true. | |
# - MissingKeyError if the key is missing and +raise_if_missing_key+ is true. | |
# - MissingContentError if the encrypted file does not exist or otherwise if the key is missing. |
eef6065
to
d64367e
Compare
Thank you, @whyinzoo! 🎉 (Backported to |
…pport--EncryptedFile-read-for-pr Add docs for ActiveSupport::EncryptedFile#read [ci-skip] (cherry picked from commit 4e9fee9)
Summary
Adding docs to ActiveSupport::EncryptedFile#read
Other Information
Found this on https://www.codetriage.com/