Improve error reporting and logging when processing remote accounts (#15605)
* Add a more descriptive PrivateNetworkAddressError exception class
* Remove unnecessary exception class to rescue clause
* Remove unnecessary include to JsonLdHelper
* Give more neutral error message when too many webfinger redirects
* Remove unnecessary guard condition
* Rework how “ActivityPub::FetchRemoteAccountService” handles errors
Add “suppress_errors” keyword argument to avoid raising errors in
ActivityPub::FetchRemoteAccountService#call (default/previous behavior).
* Rework how “ActivityPub::FetchRemoteKeyService” handles errors
Add “suppress_errors” keyword argument to avoid raising errors in
ActivityPub::FetchRemoteKeyService#call (default/previous behavior).
* Fix Webfinger::RedirectError not being a subclass of Webfinger::Error
* Add suppress_errors option to ResolveAccountService
Defaults to true (to preserve previous behavior). If set to false,
errors will be raised instead of caught, allowing the caller to be
informed of what went wrong.
* Return more precise error when failing to fetch account signing AP payloads
* Add tests
* Fixes
* Refactor error handling a bit
* Fix various issues
* Add specific error when provided Digest is not 256 bits of base64-encoded data
* Please CodeClimate
* Improve webfinger error reporting
@signature_verification_failure_reason="Verification failed for #{account.username}@#{account.domain}#{account.uri} using rsa-sha256 (RSASSA-PKCS1-v1_5 with SHA-256)"
@signed_request_account=nil
fail_with!"Verification failed for #{account.username}@#{account.domain}#{account.uri} using rsa-sha256 (RSASSA-PKCS1-v1_5 with SHA-256)"
rescueSignatureVerificationError=>e
@signature_verification_failure_reason=e.message
@signed_request_account=nil
fail_with!e.message
rescueHTTP::Error,OpenSSL::SSL::SSLError=>e
fail_with!"Failed to fetch remote data: #{e.message}"
rescueMastodon::UnexptectedResponseError
fail_with!'Failed to fetch remote data (got unexpected reply from server)'
rescueStoplight::Error::RedLight
fail_with!'Fetching attempt skipped because of recent connection failure'